Skip to content

Commit 6d6330a

Browse files
committed
Fixed Theme issue
- The selected theme will now be set after restart. - Added new selection color setting for the logging grid.
1 parent 09dda77 commit 6d6330a

15 files changed

+425
-87
lines changed

src/Couchcoding.Logbert.Theme/Couchcoding.Logbert.Theme.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
<Compile Include="Resources\VisualStudioBlueResources.cs" />
8080
<Compile Include="Resources\VisualStudioDarkResources.cs" />
8181
<Compile Include="Resources\VisualStudioLightResources.cs" />
82-
<Compile Include="Theme.cs" />
8382
<Compile Include="ThemeManager.cs" />
8483
<Compile Include="Themes\BaseTheme.cs" />
8584
<Compile Include="Themes\VisualStudioBlueTheme.cs" />

src/Couchcoding.Logbert.Theme/ThemeManager.cs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@ public static class ThemeManager
5656
/// </summary>
5757
private static BaseTheme mApplicationTheme;
5858

59-
/// <summary>
60-
/// Holds the current active <see cref="BaseTheme"/> index.
61-
/// </summary>
62-
private static Theme mActiveApplicationTheme;
63-
6459
#endregion
6560

6661
#region Public Properties
@@ -74,18 +69,7 @@ public static BaseTheme CurrentApplicationTheme
7469
{
7570
if (mApplicationTheme == null)
7671
{
77-
switch (mActiveApplicationTheme)
78-
{
79-
case Theme.VisualStudioBlue:
80-
mApplicationTheme = new VisualStudioBlueTheme();
81-
break;
82-
case Theme.VisualStudioLight:
83-
mApplicationTheme = new VisualStudioDarkTheme();
84-
break;
85-
default:
86-
mApplicationTheme = new VisualStudioLightTheme();
87-
break;
88-
}
72+
mApplicationTheme = new VisualStudioLightTheme();
8973
}
9074

9175
return mApplicationTheme;
@@ -132,12 +116,12 @@ public static void ApplyTo(Control control)
132116
}
133117

134118
/// <summary>
135-
/// Sets the current active <see cref="BaseTheme"/> by the specified <see cref="Theme"/>.
119+
/// Sets the current active <see cref="BaseTheme"/> by the specified one.
136120
/// </summary>
137121
/// <param name="themeName">The name of the Theme to apply.</param>
138-
public static void SetActiveApplicationTheme(Theme theme)
122+
public static void SetActiveApplicationTheme(BaseTheme theme)
139123
{
140-
mActiveApplicationTheme = theme;
124+
mApplicationTheme = theme;
141125
}
142126

143127
#endregion

src/Couchcoding.Logbert.Theme/Themes/BaseTheme.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,26 @@ namespace Couchcoding.Logbert.Theme.Themes
3939
/// Implements the base class for all themes.
4040
/// </summary>
4141
public abstract class BaseTheme
42-
{
42+
{
43+
#region Public Consts
44+
45+
/// <summary>
46+
/// Defines the name of the <see cref="VisualStudioLightTheme"/>.
47+
/// </summary>
48+
public const string VisualStudioThemeLightName = "Visual Studio Light";
49+
50+
/// <summary>
51+
/// Defines the name of the <see cref="VisualStudioBlueTheme"/>.
52+
/// </summary>
53+
public const string VisualStudioThemeBlueName = "Visual Studio Blue";
54+
55+
/// <summary>
56+
/// Defines the name of the <see cref="VisualStudioDarkTheme"/>.
57+
/// </summary>
58+
public const string VisualStudioThemeDarkName = "Visual Studio Dark";
59+
60+
#endregion
61+
4362
#region Private Fields
4463

4564
/// <summary>

src/Couchcoding.Logbert.Theme/Themes/VisualStudioBlueTheme.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class VisualStudioBlueTheme : BaseTheme
4545
/// <summary>
4646
/// Gets the name of the <see cref="BaseTheme"/> instance.
4747
/// </summary>
48-
public override string Name => "Visual Studio Blue";
48+
public override string Name => VisualStudioThemeBlueName;
4949

5050
#endregion
5151

src/Couchcoding.Logbert.Theme/Themes/VisualStudioDarkTheme.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class VisualStudioDarkTheme : BaseTheme
4545
/// <summary>
4646
/// Gets the name of the <see cref="BaseTheme"/> instance.
4747
/// </summary>
48-
public override string Name => "Visual Studio Dark";
48+
public override string Name => VisualStudioThemeDarkName;
4949

5050
#endregion
5151

src/Couchcoding.Logbert.Theme/Themes/VisualStudioLightTheme.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class VisualStudioLightTheme : BaseTheme
4545
/// <summary>
4646
/// Gets the name of the <see cref="BaseTheme"/> instance.
4747
/// </summary>
48-
public override string Name => "Visual Studio Light";
48+
public override string Name => VisualStudioThemeLightName;
4949

5050
#endregion
5151

src/Logbert/App.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,9 @@
558558
<setting name="PnlCustomDirSettingsEncoding" serializeAs="String">
559559
<value>1252</value>
560560
</setting>
561+
<setting name="UseInvertedColorForSelection" serializeAs="String">
562+
<value>False</value>
563+
</setting>
561564
</Couchcoding.Logbert.Properties.Settings>
562565
</userSettings>
563566
<applicationSettings>

src/Logbert/Controls/OptionPanels/OptionPanelFontColor.Designer.cs

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

src/Logbert/Controls/OptionPanels/OptionPanelFontColor.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ public override void InitializeControl()
265265

266266
cmbApplicationTheme.SelectedItem = Settings.Default.ApplicationTheme;
267267
chkDrawGrid.Checked = Settings.Default.LogWindowDrawGrid;
268+
chkUseInvertedColors.Checked = Settings.Default.UseInvertedColorForSelection;
268269

269270
mLastSelectedTheme = cmbApplicationTheme.Text;
270271
}
@@ -304,8 +305,9 @@ public override void SaveSettings()
304305
Settings.Default.FontStyleError = cmbFontStyleError.SelectedIndex == 0 ? FontStyle.Regular : FontStyle.Bold;
305306
Settings.Default.FontStyleFatal = cmbFontStyleFatal.SelectedIndex == 0 ? FontStyle.Regular : FontStyle.Bold;
306307

307-
Settings.Default.LogWindowDrawGrid = chkDrawGrid.Checked;
308-
Settings.Default.ApplicationTheme = cmbApplicationTheme.Text;
308+
Settings.Default.LogWindowDrawGrid = chkDrawGrid.Checked;
309+
Settings.Default.ApplicationTheme = cmbApplicationTheme.Text;
310+
Settings.Default.UseInvertedColorForSelection = chkUseInvertedColors.Checked;
309311

310312
Settings.Default.SaveSettings();
311313
}

src/Logbert/Dialogs/Docking/FrmLogWindow.cs

Lines changed: 53 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -401,52 +401,63 @@ private void DtgLogMessagesCellPainting(object sender, DataGridViewCellPaintingE
401401
Brush backgroundBrush = null;
402402
FontStyle fontStyle = FontStyle.Regular;
403403

404-
if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected)
404+
switch (mFilteredLogMessages[e.RowIndex].Level)
405405
{
406-
foreColor = SystemColors.HighlightText;
407-
backColor = SystemColors.MenuHighlight;
408-
backgroundBrush = GdiCache.GetBrushFromColor(backColor);
406+
case LogLevel.Trace:
407+
foreColor = Settings.Default.ForegroundColorTrace;
408+
backColor = Settings.Default.BackgroundColorTrace;
409+
fontStyle = Settings.Default.FontStyleTrace;
410+
backgroundBrush = GdiCache.GetBrushFromColor(backColor);
411+
break;
412+
case LogLevel.Debug:
413+
foreColor = Settings.Default.ForegroundColorDebug;
414+
backColor = Settings.Default.BackgroundColorDebug;
415+
fontStyle = Settings.Default.FontStyleDebug;
416+
backgroundBrush = GdiCache.GetBrushFromColor(backColor);
417+
break;
418+
case LogLevel.Info:
419+
foreColor = Settings.Default.ForegroundColorInfo;
420+
backColor = Settings.Default.BackgroundColorInfo;
421+
fontStyle = Settings.Default.FontStyleInfo;
422+
backgroundBrush = GdiCache.GetBrushFromColor(backColor);
423+
break;
424+
case LogLevel.Warning:
425+
foreColor = Settings.Default.ForegroundColorWarning;
426+
backColor = Settings.Default.BackgroundColorWarning;
427+
fontStyle = Settings.Default.FontStyleWarning;
428+
backgroundBrush = GdiCache.GetBrushFromColor(backColor);
429+
break;
430+
case LogLevel.Error:
431+
foreColor = Settings.Default.ForegroundColorError;
432+
backColor = Settings.Default.BackgroundColorError;
433+
fontStyle = Settings.Default.FontStyleError;
434+
backgroundBrush = GdiCache.GetBrushFromColor(backColor);
435+
break;
436+
case LogLevel.Fatal:
437+
foreColor = Settings.Default.ForegroundColorFatal;
438+
backColor = Settings.Default.BackgroundColorFatal;
439+
fontStyle = Settings.Default.FontStyleFatal;
440+
backgroundBrush = GdiCache.GetBrushFromColor(backColor);
441+
break;
409442
}
410-
else
443+
444+
if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected)
411445
{
412-
switch (mFilteredLogMessages[e.RowIndex].Level)
446+
if (Settings.Default.UseInvertedColorForSelection)
447+
{
448+
// Invert the colors for selected items.
449+
Color tmpForecolor = foreColor;
450+
451+
foreColor = backColor;
452+
backColor = tmpForecolor;
453+
backgroundBrush = GdiCache.GetBrushFromColor(tmpForecolor);
454+
}
455+
else
413456
{
414-
case LogLevel.Trace:
415-
foreColor = Settings.Default.ForegroundColorTrace;
416-
backColor = Settings.Default.BackgroundColorTrace;
417-
fontStyle = Settings.Default.FontStyleTrace;
418-
backgroundBrush = GdiCache.GetBrushFromColor(backColor);
419-
break;
420-
case LogLevel.Debug:
421-
foreColor = Settings.Default.ForegroundColorDebug;
422-
backColor = Settings.Default.BackgroundColorDebug;
423-
fontStyle = Settings.Default.FontStyleDebug;
424-
backgroundBrush = GdiCache.GetBrushFromColor(backColor);
425-
break;
426-
case LogLevel.Info:
427-
foreColor = Settings.Default.ForegroundColorInfo;
428-
backColor = Settings.Default.BackgroundColorInfo;
429-
fontStyle = Settings.Default.FontStyleInfo;
430-
backgroundBrush = GdiCache.GetBrushFromColor(backColor);
431-
break;
432-
case LogLevel.Warning:
433-
foreColor = Settings.Default.ForegroundColorWarning;
434-
backColor = Settings.Default.BackgroundColorWarning;
435-
fontStyle = Settings.Default.FontStyleWarning;
436-
backgroundBrush = GdiCache.GetBrushFromColor(backColor);
437-
break;
438-
case LogLevel.Error:
439-
foreColor = Settings.Default.ForegroundColorError;
440-
backColor = Settings.Default.BackgroundColorError;
441-
fontStyle = Settings.Default.FontStyleError;
442-
backgroundBrush = GdiCache.GetBrushFromColor(backColor);
443-
break;
444-
case LogLevel.Fatal:
445-
foreColor = Settings.Default.ForegroundColorFatal;
446-
backColor = Settings.Default.BackgroundColorFatal;
447-
fontStyle = Settings.Default.FontStyleFatal;
448-
backgroundBrush = GdiCache.GetBrushFromColor(backColor);
449-
break;
457+
// Use the default system colors for selected items.
458+
foreColor = SystemColors.HighlightText;
459+
backColor = SystemColors.MenuHighlight;
460+
backgroundBrush = GdiCache.GetBrushFromColor(backColor);
450461
}
451462
}
452463

0 commit comments

Comments
 (0)