Skip to content

Commit b169385

Browse files
committed
Added new settings to control the grid drawing
* The user may now disable the drawing of the grid in the messages overview. * Fixed background color for Windows XP, Vista and 7.
1 parent d5c1f21 commit b169385

File tree

12 files changed

+186
-29
lines changed

12 files changed

+186
-29
lines changed

src/Logbert/App.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,9 @@
372372
<setting name="PnlNLogDirectorySettingsReadAllExisting" serializeAs="String">
373373
<value>False</value>
374374
</setting>
375+
<setting name="LogWindowDrawGrid" serializeAs="String">
376+
<value>True</value>
377+
</setting>
375378
</Com.Couchcoding.Logbert.Properties.Settings>
376379
</userSettings>
377380
<applicationSettings>

src/Logbert/Controls/ColorMap.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
using Com.Couchcoding.Logbert.Interfaces;
3838
using Com.Couchcoding.Logbert.Logging;
3939
using Com.Couchcoding.Logbert.Properties;
40-
using WeifenLuo.WinFormsUI.Docking;
4140

4241
namespace Com.Couchcoding.Logbert.Controls
4342
{
@@ -100,6 +99,27 @@ public partial class ColorMap : UserControl
10099

101100
#endregion
102101

102+
#region Public Properties
103+
104+
/// <summary>
105+
/// Gets or sets the background color for the control.
106+
/// </summary>
107+
/// <returns>A <see cref="T:System.Drawing.Color" /> that represents the background color of the control. The default is the value of the <see cref="P:System.Windows.Forms.Control.DefaultBackColor" /> property.</returns>
108+
public sealed override Color BackColor
109+
{
110+
get
111+
{
112+
return base.BackColor;
113+
}
114+
115+
set
116+
{
117+
base.BackColor = value;
118+
}
119+
}
120+
121+
#endregion
122+
103123
#region Private Methods
104124

105125
/// <summary>
@@ -311,6 +331,8 @@ public ColorMap(ILogPresenter logPresenter)
311331

312332
InitializeComponent();
313333

334+
BackColor = ThemeManager.CurrentApplicationTheme.ColorPalette.MainWindowActive.Background;
335+
314336
mLogPresenter = logPresenter;
315337
mViewRectPadding = new Padding(
316338
0

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

Lines changed: 20 additions & 4 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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
using System.ComponentModel;
3737

3838
using Com.Couchcoding.Logbert.Helper;
39+
using Com.Couchcoding.Logbert.Interfaces;
3940
using Com.Couchcoding.Logbert.Properties;
4041

4142
namespace Com.Couchcoding.Logbert.Controls.OptionPanels
@@ -185,6 +186,8 @@ public override void InitializeControl()
185186
cmbFontStyleWarning.SelectedIndex = Settings.Default.FontStyleWarning == FontStyle.Regular ? 0 : 1;
186187
cmbFontStyleError.SelectedIndex = Settings.Default.FontStyleError == FontStyle.Regular ? 0 : 1;
187188
cmbFontStyleFatal.SelectedIndex = Settings.Default.FontStyleFatal == FontStyle.Regular ? 0 : 1;
189+
190+
chkDrawGrid.Checked = Settings.Default.LogWindowDrawGrid;
188191
}
189192

190193
/// <summary>
@@ -222,6 +225,8 @@ public override void SaveSettings()
222225
Settings.Default.FontStyleError = cmbFontStyleError.SelectedIndex == 0 ? FontStyle.Regular : FontStyle.Bold;
223226
Settings.Default.FontStyleFatal = cmbFontStyleFatal.SelectedIndex == 0 ? FontStyle.Regular : FontStyle.Bold;
224227

228+
Settings.Default.LogWindowDrawGrid = chkDrawGrid.Checked;
229+
225230
Settings.Default.SaveSettings();
226231
}
227232
}

src/Logbert/Dialogs/Docking/FrmLogWindow.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ private void DtgLogMessagesCellPainting(object sender, DataGridViewCellPaintingE
406406
{
407407
foreColor = SystemColors.HighlightText;
408408
backColor = SystemColors.MenuHighlight;
409-
backgroundBrush = BrushCache.GetBrushFromColor(backColor);
409+
backgroundBrush = GdiCache.GetBrushFromColor(backColor);
410410
}
411411
else
412412
{
@@ -415,32 +415,32 @@ private void DtgLogMessagesCellPainting(object sender, DataGridViewCellPaintingE
415415
case LogLevel.Trace:
416416
foreColor = Settings.Default.ForegroundColorTrace;
417417
backColor = Settings.Default.BackgroundColorTrace;
418-
backgroundBrush = BrushCache.GetBrushFromColor(backColor);
418+
backgroundBrush = GdiCache.GetBrushFromColor(backColor);
419419
break;
420420
case LogLevel.Debug:
421421
foreColor = Settings.Default.ForegroundColorDebug;
422422
backColor = Settings.Default.BackgroundColorDebug;
423-
backgroundBrush = BrushCache.GetBrushFromColor(backColor);
423+
backgroundBrush = GdiCache.GetBrushFromColor(backColor);
424424
break;
425425
case LogLevel.Info:
426426
foreColor = Settings.Default.ForegroundColorInfo;
427427
backColor = Settings.Default.BackgroundColorInfo;
428-
backgroundBrush = BrushCache.GetBrushFromColor(backColor);
428+
backgroundBrush = GdiCache.GetBrushFromColor(backColor);
429429
break;
430430
case LogLevel.Warning:
431431
foreColor = Settings.Default.ForegroundColorWarning;
432432
backColor = Settings.Default.BackgroundColorWarning;
433-
backgroundBrush = BrushCache.GetBrushFromColor(backColor);
433+
backgroundBrush = GdiCache.GetBrushFromColor(backColor);
434434
break;
435435
case LogLevel.Error:
436436
foreColor = Settings.Default.ForegroundColorError;
437437
backColor = Settings.Default.BackgroundColorError;
438-
backgroundBrush = BrushCache.GetBrushFromColor(backColor);
438+
backgroundBrush = GdiCache.GetBrushFromColor(backColor);
439439
break;
440440
case LogLevel.Fatal:
441441
foreColor = Settings.Default.ForegroundColorFatal;
442442
backColor = Settings.Default.BackgroundColorFatal;
443-
backgroundBrush = BrushCache.GetBrushFromColor(backColor);
443+
backgroundBrush = GdiCache.GetBrushFromColor(backColor);
444444
break;
445445
}
446446
}
@@ -469,7 +469,9 @@ private void DtgLogMessagesCellPainting(object sender, DataGridViewCellPaintingE
469469
}
470470

471471
e.Graphics.DrawRectangle(
472-
SystemPens.ControlDark
472+
Settings.Default.LogWindowDrawGrid
473+
? GdiCache.GetPenFromColor(dtgLogMessages.GridColor)
474+
: GdiCache.GetPenFromColor(backColor)
473475
, e.CellBounds);
474476

475477
e.Handled = true;

src/Logbert/Dialogs/FrmNew.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,7 @@ public partial class FrmNew : DialogForm
5959
/// <summary>
6060
/// Gets the fully configured <see cref="ILogProvider"/>, or <c>null</c> on error.
6161
/// </summary>
62-
public ILogProvider LogProvider
63-
{
64-
get
65-
{
66-
ILogSettingsCtrl settingsCtrl = grpSettings.Controls[0] as ILogSettingsCtrl;
67-
68-
return settingsCtrl != null
69-
? settingsCtrl.GetConfiguredInstance()
70-
: null;
71-
}
72-
}
62+
public ILogProvider LogProvider => (grpSettings.Controls[0] as ILogSettingsCtrl)?.GetConfiguredInstance();
7363

7464
#endregion
7565

src/Logbert/Helper/GdiCache.cs

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#region Copyright © 2015 Couchcoding
2+
3+
// File: BrushCache.cs
4+
// Package: Logbert
5+
// Project: Logbert
6+
//
7+
// The MIT License (MIT)
8+
//
9+
// Copyright (c) 2015 Couchcoding
10+
//
11+
// Permission is hereby granted, free of charge, to any person obtaining a copy
12+
// of this software and associated documentation files (the "Software"), to deal
13+
// in the Software without restriction, including without limitation the rights
14+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15+
// copies of the Software, and to permit persons to whom the Software is
16+
// furnished to do so, subject to the following conditions:
17+
//
18+
// The above copyright notice and this permission notice shall be included in
19+
// all copies or substantial portions of the Software.
20+
//
21+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27+
// THE SOFTWARE.
28+
29+
#endregion
30+
31+
using System.Collections.Generic;
32+
using System.Drawing;
33+
34+
namespace Com.Couchcoding.Logbert.Helper
35+
{
36+
/// <summary>
37+
/// Implements a cache for <see cref="Brushes"/> nad <see cref="Pen"/>s.
38+
/// </summary>
39+
public static class GdiCache
40+
{
41+
#region Private Fields
42+
43+
/// <summary>
44+
/// The one and only <see cref="Brush"/> cache.
45+
/// </summary>
46+
private static readonly Dictionary<Color, Brush> mBrushCache = new Dictionary<Color,Brush>();
47+
48+
/// <summary>
49+
/// The one and only <see cref="Pen"/> cache.
50+
/// </summary>
51+
private static readonly Dictionary<Color, Pen> mPenCache = new Dictionary<Color, Pen>();
52+
53+
/// <summary>
54+
/// Simple object for thread synchronization to access the <see cref="Brush"/>es..
55+
/// </summary>
56+
private static readonly object mBrushSync = new object();
57+
58+
/// <summary>
59+
/// Simple object for thread synchronization to access the <see cref="Pen"/>s..
60+
/// </summary>
61+
private static readonly object mPenSync = new object();
62+
63+
#endregion
64+
65+
#region Public Methods
66+
67+
/// <summary>
68+
/// Gets a cached <see cref="Brush"/> that matches the given <paramref name="color"/>.
69+
/// </summary>
70+
/// <param name="color">The <see cref="Color"/> to get a <see cref="Brush"/> for</param>
71+
/// <returns>The cached <see cref="Brush"/> that matches the given <paramref name="color"/>.</returns>
72+
public static Brush GetBrushFromColor(Color color)
73+
{
74+
lock (mBrushSync)
75+
{
76+
if (!mBrushCache.ContainsKey(color))
77+
{
78+
mBrushCache.Add(color, new SolidBrush(color));
79+
}
80+
81+
return mBrushCache[color];
82+
}
83+
}
84+
85+
/// <summary>
86+
/// Gets a cached <see cref="Pen"/> that matches the given <paramref name="color"/>.
87+
/// </summary>
88+
/// <param name="color">The <see cref="Color"/> to get a <see cref="Pen"/> for</param>
89+
/// <returns>The cached <see cref="Pen"/> that matches the given <paramref name="color"/>.</returns>
90+
public static Pen GetPenFromColor(Color color)
91+
{
92+
lock (mPenSync)
93+
{
94+
if (!mPenCache.ContainsKey(color))
95+
{
96+
mPenCache.Add(color, new Pen(color));
97+
}
98+
99+
return mPenCache[color];
100+
}
101+
}
102+
103+
#endregion
104+
}
105+
}

src/Logbert/Logbert.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@
244244
<Compile Include="Dialogs\FrmOptions.Designer.cs">
245245
<DependentUpon>FrmOptions.cs</DependentUpon>
246246
</Compile>
247-
<Compile Include="Helper\BrushCache.cs" />
247+
<Compile Include="Helper\GdiCache.cs" />
248248
<Compile Include="Helper\Extensions.cs" />
249249
<Compile Include="Helper\FlatColorTable.cs" />
250250
<Compile Include="Helper\Logger.cs" />

src/Logbert/MainForm.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,9 +763,8 @@ public MainForm(string logFileToLoad)
763763
mainDockPanel.Theme = ThemeManager.CurrentApplicationTheme;
764764
mainDockPanel.Theme.ApplyTo(mnuMain);
765765

766+
mainDockPanel.BackColor = mainDockPanel.DockBackColor;
766767
mainDockPanel.BackgroundImage = Resources.Logbert_Start_Screen;
767-
mainDockPanel.BackColor = SystemColors.Control;
768-
mainDockPanel.DockBackColor = SystemColors.Control;
769768

770769
// Ensure we're using the systems default dialog font for the main view.
771770
Font = SystemFonts.MessageBoxFont;

src/Logbert/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@
2929
// Build Number
3030
// Revision
3131
//
32-
[assembly: AssemblyVersion("1.2.1.0")]
33-
[assembly: AssemblyFileVersion("1.2.1.0")]
32+
[assembly: AssemblyVersion("1.2.1.1")]
33+
[assembly: AssemblyFileVersion("1.2.1.1")]
3434
[assembly: NeutralResourcesLanguageAttribute("")]

0 commit comments

Comments
 (0)