Skip to content

Commit e6fc94d

Browse files
Testing and fixing issues
1 parent 25196ce commit e6fc94d

File tree

12 files changed

+259
-98
lines changed

12 files changed

+259
-98
lines changed

src/Sample/TestApplication/LogVieweer.Designer.cs

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

src/Sample/TestApplicationNet6/Form1.Designer.cs

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

src/Sample/TestApplicationNet6/Form1.resx

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,64 @@
1-
<root>
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<root>
3+
<!--
4+
Microsoft ResX Schema
5+
6+
Version 2.0
7+
8+
The primary goals of this format is to allow a simple XML format
9+
that is mostly human readable. The generation and parsing of the
10+
various data types are done through the TypeConverter classes
11+
associated with the data types.
12+
13+
Example:
14+
15+
... ado.net/XML headers & schema ...
16+
<resheader name="resmimetype">text/microsoft-resx</resheader>
17+
<resheader name="version">2.0</resheader>
18+
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19+
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20+
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21+
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22+
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23+
<value>[base64 mime encoded serialized .NET Framework object]</value>
24+
</data>
25+
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26+
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27+
<comment>This is a comment</comment>
28+
</data>
29+
30+
There are any number of "resheader" rows that contain simple
31+
name/value pairs.
32+
33+
Each data row contains a name, and value. The row also contains a
34+
type or mimetype. Type corresponds to a .NET class that support
35+
text/value conversion through the TypeConverter architecture.
36+
Classes that don't support this are serialized and stored with the
37+
mimetype set.
38+
39+
The mimetype is used for serialized objects, and tells the
40+
ResXResourceReader how to depersist the object. This is currently not
41+
extensible. For a given mimetype the value must be set accordingly:
42+
43+
Note - application/x-microsoft.net.object.binary.base64 is the format
44+
that the ResXResourceWriter will generate, however the reader can
45+
read any of the formats listed below.
46+
47+
mimetype: application/x-microsoft.net.object.binary.base64
48+
value : The object must be serialized with
49+
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50+
: and then encoded with base64 encoding.
51+
52+
mimetype: application/x-microsoft.net.object.soap.base64
53+
value : The object must be serialized with
54+
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55+
: and then encoded with base64 encoding.
56+
57+
mimetype: application/x-microsoft.net.object.bytearray.base64
58+
value : The object must be serialized into a byte array
59+
: using a System.ComponentModel.TypeConverter
60+
: and then encoded with base64 encoding.
61+
-->
262
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
363
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
464
<xsd:element name="root" msdata:IsDataSet="true">

src/Sample/TestApplicationNet6/TestApplicationNet6.csproj renamed to src/Sample/TestApplicationNet6/TestApplicationNet9.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>WinExe</OutputType>
5-
<TargetFramework>net6.0-windows</TargetFramework>
5+
<TargetFramework>net9.0-windows</TargetFramework>
66
<Nullable>enable</Nullable>
77
<UseWindowsForms>true</UseWindowsForms>
88
<ImplicitUsings>enable</ImplicitUsings>

src/Serilog.Sinks.WinForms.Core/JsonLogTextBox.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ namespace Serilog.Sinks.WinForms.Core
55
{
66
public partial class JsonLogTextBox : UserControl
77
{
8-
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
8+
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
99
public ScrollBars ScrollBars { get; set; }
1010

11-
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
11+
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
1212
public Padding LogPadding { get; set; } = new Padding(3, 3, 3, 3);
1313

14-
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
14+
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
1515
public bool ReadOnly { get; set; }
1616

17-
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
17+
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
1818
public BorderStyle LogBorderStyle { get; set; } = BorderStyle.Fixed3D;
19-
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
19+
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
2020
public string ForContext { get; set; } = string.Empty;
2121

2222
private bool _isContextConfigured = false;

src/Serilog.Sinks.WinForms.Core/RichTextBoxLogControl.cs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,41 @@ namespace Serilog.Sinks.WinForms.Core
55
{
66
public partial class RichTextBoxLogControl : RichTextBox
77
{
8-
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
9-
public string ForContext { get; set; } = string.Empty;
8+
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
9+
[Category("Serilog Sink WinForms")] public string ForContext { get; set; } = string.Empty;
10+
11+
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
12+
[Category("Serilog Sink WinForms")] public bool AutoPurge { get; set; }
13+
14+
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
15+
[Category("Serilog Sink WinForms")] public double AutoPurgeTime { get; set; } = 60;
16+
17+
private System.Windows.Forms.Timer _timer = default!;
1018

1119
public RichTextBoxLogControl()
1220
{
1321
InitializeComponent();
1422
WindFormsSink.SimpleTextBoxSink.OnLogReceived += SimpleTextBoxSinkOnLogReceived;
1523

16-
HandleDestroyed += ( sender, args ) =>
24+
HandleDestroyed += (sender, args) =>
1725
{
1826
WindFormsSink.SimpleTextBoxSink.OnLogReceived -= SimpleTextBoxSinkOnLogReceived;
1927
};
28+
29+
if (AutoPurge)
30+
{
31+
_timer = new System.Windows.Forms.Timer
32+
{
33+
Interval = Convert.ToInt32(TimeSpan.FromMinutes(AutoPurgeTime).TotalMilliseconds)
34+
};
35+
_timer.Tick += _timer_Tick;
36+
_timer.Start();
37+
}
38+
}
39+
40+
private void _timer_Tick(object sender, EventArgs e)
41+
{
42+
ClearLogs();
2043
}
2144

2245
private void SimpleTextBoxSinkOnLogReceived(string context, string str)
@@ -38,7 +61,7 @@ private void PrintText(string str)
3861
{
3962
if (this.InvokeRequired)
4063
{
41-
this.Invoke((MethodInvoker) delegate
64+
this.Invoke((MethodInvoker)delegate
4265
{
4366
this.AppendText(str);
4467
this.ScrollToCaret();

src/Serilog.Sinks.WinForms.Core/SimpleLogTextBox.cs

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,28 @@ public partial class SimpleLogTextBox : UserControl
77
{
88
private bool _isContextConfigured = false;
99

10-
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
11-
public ScrollBars ScrollBars { get; set; }
10+
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
11+
[Category("Serilog Sink WinForms")] public ScrollBars ScrollBars { get; set; }
1212

13-
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
14-
public Padding LogPadding { get; set; } = new Padding(3, 3, 3, 3);
13+
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
14+
[Category("Serilog Sink WinForms")] public Padding LogPadding { get; set; } = new Padding(3, 3, 3, 3);
1515

16-
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
17-
public bool ReadOnly { get; set; }
16+
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
17+
[Category("Serilog Sink WinForms")] public bool ReadOnly { get; set; }
1818

19-
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
20-
public string ForContext { get; set; } = string.Empty;
19+
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
20+
[Category("Serilog Sink WinForms")] public string ForContext { get; set; } = string.Empty;
2121

22-
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
23-
public BorderStyle LogBorderStyle { get; set; } = BorderStyle.Fixed3D;
22+
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
23+
[Category("Serilog Sink WinForms")] public BorderStyle LogBorderStyle { get; set; } = BorderStyle.Fixed3D;
2424

25+
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
26+
[Category("Serilog Sink WinForms")] public bool AutoPurge { get; set; }
27+
28+
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
29+
[Category("Serilog Sink WinForms")] public double AutoPurgeTime { get; set; } = 60;
30+
31+
private System.Windows.Forms.Timer _timer = default!;
2532

2633
public SimpleLogTextBox()
2734
{
@@ -41,10 +48,25 @@ private void LogTextBox_Load(object sender, EventArgs e)
4148

4249
WindFormsSink.SimpleTextBoxSink.OnLogReceived += SimpleTextBoxSinkOnLogReceived;
4350

44-
HandleDestroyed += ( handler, args ) =>
51+
HandleDestroyed += (handler, args) =>
4552
{
4653
WindFormsSink.SimpleTextBoxSink.OnLogReceived -= SimpleTextBoxSinkOnLogReceived;
4754
};
55+
56+
if (AutoPurge)
57+
{
58+
_timer = new System.Windows.Forms.Timer
59+
{
60+
Interval = Convert.ToInt32(TimeSpan.FromMinutes(AutoPurgeTime).TotalMilliseconds)
61+
};
62+
_timer.Tick += _timer_Tick;
63+
_timer.Start();
64+
}
65+
}
66+
67+
private void _timer_Tick(object sender, EventArgs e)
68+
{
69+
ClearLogs();
4870
}
4971

5072
private void SimpleTextBoxSinkOnLogReceived(string context, string str)

0 commit comments

Comments
 (0)