Skip to content

Commit e2c60b8

Browse files
committed
UI improvements and addressed issue #6.
* Fixed wrong color for new treeview and log items * The statistics chart can now be turned around * Addressed issue #6
1 parent ad23c6d commit e2c60b8

File tree

11 files changed

+148
-111
lines changed

11 files changed

+148
-111
lines changed

src/Couchcoding.Logbert.Gui/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("1.5.4.0")]
35-
[assembly: AssemblyFileVersion("1.5.4.0")]
34+
[assembly: AssemblyVersion("1.5.5.0")]
35+
[assembly: AssemblyFileVersion("1.5.5.0")]

src/Couchcoding.Logbert.Theme/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("1.5.4.0")]
35-
[assembly: AssemblyFileVersion("1.5.4.0")]
34+
[assembly: AssemblyVersion("1.5.5.0")]
35+
[assembly: AssemblyFileVersion("1.5.5.0")]

src/Logbert/Dialogs/Docking/FrmLogStatistic.Designer.cs

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

src/Logbert/Dialogs/Docking/FrmLogStatistic.cs

Lines changed: 117 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,32 @@
4343
using Couchcoding.Logbert.Theme.Interfaces;
4444
using Couchcoding.Logbert.Theme;
4545
using Couchcoding.Logbert.Theme.Themes;
46+
using System.Windows.Forms;
4647

4748
namespace Couchcoding.Logbert.Dialogs.Docking
4849
{
4950
/// <summary>
5051
/// Implements the <see cref="DockContent"/> of the statistic window.
5152
/// </summary>
5253
public partial class FrmLogStatistic : DockContent, ILogPresenter, IThemable
53-
{
54+
{
55+
#region Private Fields
56+
57+
private Point mMousePoint = Point.Empty;
58+
private int mStartInclination = 0;
59+
private int mStartRotation = 0;
60+
61+
/// <summary>
62+
/// Simple object for thread synchronization.
63+
/// </summary>
64+
private static object mSyncRoot = new object();
65+
private volatile bool mInUpdate;
66+
private delegate void UpdateChartDelegate(List<LogMessage> messages);
67+
68+
#endregion
69+
5470
#region Public Properties
55-
71+
5672
/// <summary>
5773
/// Gets the count of currently displayed <see cref="LogMessage"/>s.
5874
/// </summary>
@@ -100,11 +116,104 @@ public void LogMessagesChanged(List<LogMessage> messages, int delta = -1)
100116
}
101117

102118
/// <summary>
103-
/// Simple object for thread synchronization.
119+
/// Selects the given <paramref name="message"/>.
104120
/// </summary>
105-
private static object mSyncRoot = new object();
106-
private volatile bool mInUpdate;
107-
private delegate void UpdateChartDelegate(List<LogMessage> messages);
121+
/// <param name="message">The <see cref="LogMessage"/> o select</param>
122+
/// <returns><c>True</c> if the given <paramref name="message"/> was selected successfully, otherwise <c>false</c>.</returns>
123+
public bool SelectLogMessage(LogMessage message)
124+
{
125+
// Nothing to do here.
126+
return true;
127+
}
128+
129+
/// <summary>
130+
/// Selects the <see cref="LogMessage"/> on the given <paramref name="index"/>.
131+
/// </summary>
132+
/// <param name="index">The index of the <see cref="LogMessage"/> to select.</param>
133+
/// <returns><c>True</c> if the <see cref="LogMessage"/> of the given <paramref name="index"/> was selected successfully, otherwise <c>false</c>.</returns>
134+
public bool SelectLogMessage(int index)
135+
{
136+
// Nothing to do here.
137+
return true;
138+
}
139+
140+
/// <summary>
141+
/// Increases the size of the <see cref="ILogPresenter"/> content.
142+
/// </summary>
143+
/// <returns><c>True</c> if further increasing is possible, otherwise <c>false</c>.</returns>
144+
public bool ZoomIn()
145+
{
146+
return false;
147+
}
148+
149+
/// <summary>
150+
/// Decreases the size of the <see cref="ILogPresenter"/> content.
151+
/// </summary>
152+
/// <returns><c>True</c> if further decreasing is possible, otherwise <c>false</c>.</returns>
153+
public bool ZoomOut()
154+
{
155+
return false;
156+
}
157+
158+
/// <summary>
159+
/// Applies the current theme to the <see cref="Control"/>.
160+
/// </summary>
161+
/// <param name="theme">The <see cref="BaseTheme"/> instance to apply.</param>
162+
public void ApplyTheme(BaseTheme theme)
163+
{
164+
tsbShowLegend.Image = theme.Resources.Images["FrmStatisticTbLegend"];
165+
166+
chrtOverview.BackColor = theme.ColorPalette.ContentBackground;
167+
chrtOverview.ForeColor = theme.ColorPalette.ContentForeground;
168+
169+
chrtOverview.ChartAreas[0].BackColor = theme.ColorPalette.ContentBackground;
170+
171+
chrtOverview.Series[0].LabelBackColor = theme.ColorPalette.ContentBackground;
172+
chrtOverview.Series[0].LabelForeColor = theme.ColorPalette.ContentForeground;
173+
174+
chrtOverview.Legends[0].BackColor = theme.ColorPalette.ContentBackground;
175+
chrtOverview.Legends[0].ForeColor = theme.ColorPalette.ContentForeground;
176+
}
177+
178+
#endregion
179+
180+
#region Private Methods
181+
182+
private void ChrtOverviewMouseMove(object sender, MouseEventArgs e)
183+
{
184+
if (e.Button == MouseButtons.Left)
185+
{
186+
int newValY = mStartInclination - (e.Location.Y - mMousePoint.Y);
187+
int newValX = mStartRotation - (e.Location.X - mMousePoint.X);
188+
189+
chrtOverview.ChartAreas[0].Area3DStyle.Inclination = newValY < -90 ? -90 : newValY > 90 ? 90 : newValY;
190+
chrtOverview.ChartAreas[0].Area3DStyle.Rotation = newValX < -180 ? -180 : newValX > 180 ? 180 : newValX;
191+
}
192+
}
193+
194+
private void ChrtOverviewMouseDown(object sender, MouseEventArgs e)
195+
{
196+
if (e.Button == MouseButtons.Left)
197+
{
198+
mMousePoint = e.Location;
199+
mStartInclination = chrtOverview.ChartAreas[0].Area3DStyle.Inclination;
200+
mStartRotation = chrtOverview.ChartAreas[0].Area3DStyle.Rotation;
201+
202+
chrtOverview.Cursor = Cursors.SizeAll;
203+
}
204+
}
205+
206+
private void ChrtOverviewMouseUp(object sender, MouseEventArgs e)
207+
{
208+
if (e.Button == MouseButtons.Left)
209+
{
210+
mMousePoint = Point.Empty;
211+
mStartInclination = 0;
212+
mStartRotation = 0;
213+
214+
chrtOverview.Cursor = Cursors.Default;
215+
}
216+
}
108217

109218
private void StartUpdateChart(List<LogMessage> messages)
110219
{
@@ -181,70 +290,6 @@ private void UpdateChartCallback(IAsyncResult ar)
181290
BeginInvoke(new Action(EndUpdateChart));
182291
}
183292

184-
/// <summary>
185-
/// Selects the given <paramref name="message"/>.
186-
/// </summary>
187-
/// <param name="message">The <see cref="LogMessage"/> o select</param>
188-
/// <returns><c>True</c> if the given <paramref name="message"/> was selected successfully, otherwise <c>false</c>.</returns>
189-
public bool SelectLogMessage(LogMessage message)
190-
{
191-
// Nothing to do here.
192-
return true;
193-
}
194-
195-
/// <summary>
196-
/// Selects the <see cref="LogMessage"/> on the given <paramref name="index"/>.
197-
/// </summary>
198-
/// <param name="index">The index of the <see cref="LogMessage"/> to select.</param>
199-
/// <returns><c>True</c> if the <see cref="LogMessage"/> of the given <paramref name="index"/> was selected successfully, otherwise <c>false</c>.</returns>
200-
public bool SelectLogMessage(int index)
201-
{
202-
// Nothing to do here.
203-
return true;
204-
}
205-
206-
/// <summary>
207-
/// Increases the size of the <see cref="ILogPresenter"/> content.
208-
/// </summary>
209-
/// <returns><c>True</c> if further increasing is possible, otherwise <c>false</c>.</returns>
210-
public bool ZoomIn()
211-
{
212-
return false;
213-
}
214-
215-
/// <summary>
216-
/// Decreases the size of the <see cref="ILogPresenter"/> content.
217-
/// </summary>
218-
/// <returns><c>True</c> if further decreasing is possible, otherwise <c>false</c>.</returns>
219-
public bool ZoomOut()
220-
{
221-
return false;
222-
}
223-
224-
/// <summary>
225-
/// Applies the current theme to the <see cref="Control"/>.
226-
/// </summary>
227-
/// <param name="theme">The <see cref="BaseTheme"/> instance to apply.</param>
228-
public void ApplyTheme(BaseTheme theme)
229-
{
230-
tsbShowLegend.Image = theme.Resources.Images["FrmStatisticTbLegend"];
231-
232-
chrtOverview.BackColor = theme.ColorPalette.ContentBackground;
233-
chrtOverview.ForeColor = theme.ColorPalette.ContentForeground;
234-
235-
chrtOverview.ChartAreas[0].BackColor = theme.ColorPalette.ContentBackground;
236-
237-
chrtOverview.Series[0].LabelBackColor = theme.ColorPalette.ContentBackground;
238-
chrtOverview.Series[0].LabelForeColor = theme.ColorPalette.ContentForeground;
239-
240-
chrtOverview.Legends[0].BackColor = theme.ColorPalette.ContentBackground;
241-
chrtOverview.Legends[0].ForeColor = theme.ColorPalette.ContentForeground;
242-
}
243-
244-
#endregion
245-
246-
#region Private Methods
247-
248293
/// <summary>
249294
/// Gets the <see cref="DataPoint"/> that represents the specified <paramref name="level"/>.
250295
/// </summary>
@@ -356,8 +401,8 @@ public FrmLogStatistic(ILogProvider logProvider)
356401

357402
// Apply the current application theme to the control.
358403
ThemeManager.ApplyTo(this);
359-
}
360-
404+
}
405+
361406
#endregion
362407
}
363408
}

src/Logbert/Dialogs/Docking/FrmLogTree.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ private static void PopulateTreeView(TreeView treeView, string path)
159159

160160
if (lastNode.Parent != null)
161161
{
162-
lastNode.ForeColor = lastNode.Parent.ForeColor;
162+
lastNode.ForeColor = ThemeManager.CurrentApplicationTheme.ColorPalette.ContentForeground;
163163
lastNode.Parent.Expand();
164164
}
165165
}
@@ -169,10 +169,13 @@ private static void PopulateTreeView(TreeView treeView, string path)
169169
}
170170
}
171171

172-
if (treeView.SelectedNode == null && treeView.Nodes.Count > 0)
172+
if (treeView.Nodes.Count > 0)
173173
{
174-
// Initial select the very first node popupulated.
175-
treeView.SelectedNode = treeView.Nodes[0];
174+
if (treeView.SelectedNode == null)
175+
{
176+
// Initial select the very first node popupulated.
177+
treeView.SelectedNode = treeView.Nodes[0];
178+
}
176179

177180
SetNodeColor(treeView.Nodes[0]
178181
, ThemeManager.CurrentApplicationTheme.ColorPalette.ContentForeground

src/Logbert/Dialogs/Docking/FrmLogWindow.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Logbert/Dialogs/Docking/FrmLogWindow.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,8 @@ private void DtgLogMessagesCellPainting(object sender, DataGridViewCellPaintingE
475475
else
476476
{
477477
Font logFont = FontCache.GetFontFromIdentifier(
478-
Settings.Default.LogMessagesFontName
479-
, Settings.Default.LogMessagesFontSize
478+
e.CellStyle.Font.Name
479+
, e.CellStyle.Font.Size
480480
, fontStyle);
481481

482482
TextRenderer.DrawText(
@@ -505,12 +505,7 @@ private void DtgLogMessagesCellPainting(object sender, DataGridViewCellPaintingE
505505
/// <param name="e">The <see cref="LogMessageSelectedEventArgs"/> that may contain necessary information.</param>
506506
private void OnRaiseLogMessageSelectedEvent(LogMessageSelectedEventArgs e)
507507
{
508-
EventHandler<LogMessageSelectedEventArgs> handler = OnLogMessageSelected;
509-
510-
if (handler != null)
511-
{
512-
handler(this, e);
513-
}
508+
OnLogMessageSelected?.Invoke(this, e);
514509
}
515510

516511
/// <summary>
@@ -976,6 +971,8 @@ public bool ZoomIn()
976971
, dtgLogMessages.DefaultCellStyle.Font.Size + 1
977972
, FontStyle.Regular);
978973

974+
dtgLogMessages.Font = dtgLogMessages.DefaultCellStyle.Font;
975+
979976
++mRowHeight;
980977

981978
dtgLogMessages.AutoResizeRows(
@@ -1017,6 +1014,8 @@ public bool ZoomOut()
10171014
, dtgLogMessages.DefaultCellStyle.Font.Size - 1
10181015
, FontStyle.Regular);
10191016

1017+
dtgLogMessages.Font = dtgLogMessages.DefaultCellStyle.Font;
1018+
10201019
--mRowHeight;
10211020

10221021
dtgLogMessages.AutoResizeRows(

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.5.4.0")]
33-
[assembly: AssemblyFileVersion("1.5.4.0")]
32+
[assembly: AssemblyVersion("1.5.5.0")]
33+
[assembly: AssemblyFileVersion("1.5.5.0")]
3434
[assembly: NeutralResourcesLanguageAttribute("")]

src/Logbert/Receiver/CustomReceiver/CustomUdpReceiver/CustomUdpReceiver.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ private void ReceiveUdpMessage(IAsyncResult ar)
265265
{
266266
UdpClient client = ((UdpState)ar.AsyncState).Client;
267267

268-
IPEndPoint wantedIpEndPoint = ((UdpState)(ar.AsyncState)).EndPoint;
269268
IPEndPoint receivedIpEndPoint = new IPEndPoint(IPAddress.Any, 0);
270269

271270
byte[] receiveBytes;
@@ -282,10 +281,7 @@ private void ReceiveUdpMessage(IAsyncResult ar)
282281
return;
283282
}
284283

285-
bool isRightHost = (wantedIpEndPoint.Address.Equals(receivedIpEndPoint.Address))
286-
|| wantedIpEndPoint.Address.Equals(IPAddress.Any);
287-
288-
if (isRightHost && receiveBytes != null)
284+
if (receiveBytes != null)
289285
{
290286
try
291287
{

src/Logbert/Receiver/Log4NetUdpReceiver/Log4NetUdpReceiver.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,9 @@ private void ReceiveUdpMessage(IAsyncResult ar)
250250
{
251251
UdpClient client = ((UdpState)ar.AsyncState).Client;
252252

253-
IPEndPoint wantedIpEndPoint = ((UdpState)(ar.AsyncState)).EndPoint;
254253
IPEndPoint receivedIpEndPoint = new IPEndPoint(IPAddress.Any, 0);
255254

256-
Byte[] receiveBytes;
255+
byte[] receiveBytes;
257256

258257
try
259258
{
@@ -267,10 +266,7 @@ private void ReceiveUdpMessage(IAsyncResult ar)
267266
return;
268267
}
269268

270-
bool isRightHost = (wantedIpEndPoint.Address.Equals(receivedIpEndPoint.Address))
271-
|| wantedIpEndPoint.Address.Equals(IPAddress.Any);
272-
273-
if (isRightHost && receiveBytes != null)
269+
if (receiveBytes != null)
274270
{
275271
try
276272
{

0 commit comments

Comments
 (0)