Skip to content

Commit 5ea1e93

Browse files
committed
Fixed issue #8
The message part of the details window adjust now its height proper than before.
1 parent 2f24e0d commit 5ea1e93

11 files changed

+578
-514
lines changed

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

+2-2
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.5.0")]
35-
[assembly: AssemblyFileVersion("1.5.5.0")]
34+
[assembly: AssemblyVersion("1.5.5.1")]
35+
[assembly: AssemblyFileVersion("1.5.5.1")]

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

+2-2
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.5.0")]
35-
[assembly: AssemblyFileVersion("1.5.5.0")]
34+
[assembly: AssemblyVersion("1.5.5.1")]
35+
[assembly: AssemblyFileVersion("1.5.5.1")]

src/Logbert/Controls/CustomDetailsControl.Designer.cs

+154-154
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Logbert/Controls/CustomDetailsControl.cs

+21-3
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,22 @@ protected override void Dispose(bool disposing)
235235

236236
base.Dispose(disposing);
237237
}
238+
239+
/// <summary>
240+
/// Handles the size changed event of the <see cref="Control"/>.
241+
/// </summary>
242+
protected override void OnSizeChanged(EventArgs e)
243+
{
244+
base.OnSizeChanged(e);
245+
246+
foreach (Control ctrl in tblLogMessage.Controls)
247+
{
248+
if (ctrl is TextBox txtBox)
249+
{
250+
txtBox.AdjustHeightToContent();
251+
}
252+
}
253+
}
238254

239255
/// <summary>
240256
/// Adds a new log message row to the message window.
@@ -359,7 +375,8 @@ public bool SelectLogMessage(LogMessage message)
359375
continue;
360376
}
361377

362-
txtBox.Text = logMessage.GetValueForColumn(mColumnizer.Columns.IndexOf((LogColumn)txtBox.Tag) + 2).ToString();
378+
txtBox.Text = logMessage.GetValueForColumn(mColumnizer.Columns.IndexOf((LogColumn)txtBox.Tag) + 2).ToString();
379+
txtBox.AdjustHeightToContent();
363380
}
364381
}
365382
else
@@ -378,14 +395,15 @@ public bool SelectLogMessage(LogMessage message)
378395
continue;
379396
}
380397

381-
txtBox.Text = string.Empty;
398+
txtBox.Text = string.Empty;
399+
txtBox.AdjustHeightToContent();
382400
}
383401
}
384402

385403
pbxCopyNumber.Visible = !string.IsNullOrEmpty(txtDataNumber.Text);
386404
}
387405
finally
388-
{
406+
{
389407
this.ResumeDrawing();
390408
}
391409

src/Logbert/Controls/EventLogDetailsControl.cs

+11
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,17 @@ protected override void Dispose(bool disposing)
271271
base.Dispose(disposing);
272272
}
273273

274+
/// <summary>
275+
/// Handles the size changed event of the <see cref="Control"/>.
276+
/// </summary>
277+
protected override void OnSizeChanged(EventArgs e)
278+
{
279+
base.OnSizeChanged(e);
280+
281+
txtDataCategory.AdjustHeightToContent();
282+
txtDataMessage.AdjustHeightToContent();
283+
}
284+
274285
#endregion
275286

276287
#region Public Methods

src/Logbert/Controls/Log4NetDetailsControl.cs

+11
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,17 @@ protected override void Dispose(bool disposing)
261261
base.Dispose(disposing);
262262
}
263263

264+
/// <summary>
265+
/// Handles the size changed event of the <see cref="Control"/>.
266+
/// </summary>
267+
protected override void OnSizeChanged(EventArgs e)
268+
{
269+
base.OnSizeChanged(e);
270+
271+
txtDataMessage.AdjustHeightToContent();
272+
txtDataProperties.AdjustHeightToContent();
273+
}
274+
264275
#endregion
265276

266277
#region Public Methods

src/Logbert/Controls/SyslogDetailsControl.cs

+11
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,17 @@ protected override void Dispose(bool disposing)
259259
base.Dispose(disposing);
260260
}
261261

262+
/// <summary>
263+
/// Handles the size changed event of the <see cref="Control"/>.
264+
/// </summary>
265+
protected override void OnSizeChanged(EventArgs e)
266+
{
267+
base.OnSizeChanged(e);
268+
269+
txtDataFacility.AdjustHeightToContent();
270+
txtDataMessage.AdjustHeightToContent();
271+
}
272+
262273
#endregion
263274

264275
#region Public Methods

src/Logbert/Controls/WinDebugDetailsControl.Designer.cs

+343-343
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Logbert/Controls/WinDebugDetailsControl.cs

+11
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,17 @@ protected override void Dispose(bool disposing)
235235
base.Dispose(disposing);
236236
}
237237

238+
/// <summary>
239+
/// Handles the size changed event of the <see cref="Control"/>.
240+
/// </summary>
241+
protected override void OnSizeChanged(EventArgs e)
242+
{
243+
base.OnSizeChanged(e);
244+
245+
txtDataProcessId.AdjustHeightToContent();
246+
txtDataMessage.AdjustHeightToContent();
247+
}
248+
238249
#endregion
239250

240251
#region Public Methods

src/Logbert/Helper/Extensions.cs

+10-8
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ public static class Extensions
5252
/// </summary>
5353
private const int WM_SETREDRAW = 0xB;
5454

55+
/// <summary>
56+
/// The line count of a textbox control.
57+
/// </summary>
58+
private const int EM_GETLINECOUNT = 0xba;
59+
5560
#endregion
5661

5762
#region External Methods
@@ -135,15 +140,12 @@ public static void CopyToClipboard(this Control source, string text)
135140
/// <param name="txtBox">The <see cref="TextBox"/> to adjust the height of.</param>
136141
public static void AdjustHeightToContent(this TextBox txtBox)
137142
{
138-
if (txtBox != null && txtBox.ClientSize.Width > 1)
143+
if (txtBox != null && txtBox.IsHandleCreated && txtBox.ClientSize.Width > 1)
139144
{
140-
Size sz = TextRenderer.MeasureText(
141-
txtBox.Text ?? " "
142-
, txtBox.Font
143-
, new Size(txtBox.ClientSize.Width, int.MaxValue)
144-
, TextFormatFlags.WordBreak);
145-
146-
txtBox.Height = sz.Height + (txtBox.Height - txtBox.ClientSize.Height);
145+
txtBox.Height = (txtBox.Font.Height) * SendMessage(txtBox.Handle
146+
, EM_GETLINECOUNT
147+
, 0
148+
, 0) + txtBox.Margin.Bottom;
147149
}
148150
}
149151

src/Logbert/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@
2929
// Build Number
3030
// Revision
3131
//
32-
[assembly: AssemblyVersion("1.5.5.0")]
33-
[assembly: AssemblyFileVersion("1.5.5.0")]
32+
[assembly: AssemblyVersion("1.5.5.1")]
33+
[assembly: AssemblyFileVersion("1.5.5.1")]
3434
[assembly: NeutralResourcesLanguageAttribute("")]

0 commit comments

Comments
 (0)