Winify – Diff between revs 44 and 69
?pathlinks?
Rev 44 | Rev 69 | |||
---|---|---|---|---|
1 | using System.Collections.Specialized; |
1 | using System.Collections.Specialized; |
|
2 | using System.Threading; |
2 | using System.Threading; |
|
3 | using System.Windows.Forms; |
3 | using System.Windows.Forms; |
|
4 | using Winify.Utilities; |
4 | using Winify.Utilities; |
|
5 | |
5 | |
|
6 | namespace Winify |
6 | namespace Winify |
|
7 | { |
7 | { |
|
8 | public partial class LogViewForm : Form |
8 | public partial class LogViewForm : Form |
|
9 | { |
9 | { |
|
10 | private readonly CancellationToken _cancellationToken; |
10 | private readonly CancellationToken _cancellationToken; |
|
11 | |
11 | |
|
12 | private readonly MainForm _mainForm; |
12 | private readonly MainForm _mainForm; |
|
13 | |
13 | |
|
14 | private readonly LogMemorySink _memorySink; |
14 | private readonly LogMemorySink _memorySink; |
|
15 | |
15 | |
|
16 | public LogViewForm() |
16 | public LogViewForm() |
|
17 | { |
17 | { |
|
18 | InitializeComponent(); |
18 | InitializeComponent(); |
|
19 | |
- | ||
20 | Utilities.WindowState.FormTracker.Track(this); |
- | ||
21 | } |
19 | } |
|
22 | |
20 | |
|
23 | public LogViewForm(MainForm mainForm) : this() |
21 | public LogViewForm(MainForm mainForm) : this() |
|
24 | { |
22 | { |
|
25 | _mainForm = mainForm; |
23 | _mainForm = mainForm; |
|
26 | _mainForm.MemorySinkEnabled = true; |
24 | _mainForm.MemorySinkEnabled = true; |
|
27 | } |
25 | } |
|
28 | |
26 | |
|
29 | public LogViewForm(MainForm mainForm, LogMemorySink memorySink, CancellationToken cancellationToken) : |
27 | public LogViewForm(MainForm mainForm, LogMemorySink memorySink, CancellationToken cancellationToken) : |
|
30 | this(mainForm) |
28 | this(mainForm) |
|
31 | { |
29 | { |
|
32 | _memorySink = memorySink; |
30 | _memorySink = memorySink; |
|
33 | _memorySink.Events.CollectionChanged += Events_CollectionChanged; |
31 | _memorySink.Events.CollectionChanged += Events_CollectionChanged; |
|
34 | |
32 | |
|
35 | _cancellationToken = cancellationToken; |
33 | _cancellationToken = cancellationToken; |
|
36 | } |
34 | } |
|
37 | |
35 | |
|
38 | /// <summary> |
36 | /// <summary> |
|
39 | /// Clean up any resources being used. |
37 | /// Clean up any resources being used. |
|
40 | /// </summary> |
38 | /// </summary> |
|
41 | /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> |
39 | /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> |
|
42 | protected override void Dispose(bool disposing) |
40 | protected override void Dispose(bool disposing) |
|
43 | { |
41 | { |
|
44 | if (disposing && components != null) components.Dispose(); |
42 | if (disposing && components != null) components.Dispose(); |
|
45 | |
43 | |
|
46 | _memorySink.Events.CollectionChanged -= Events_CollectionChanged; |
44 | _memorySink.Events.CollectionChanged -= Events_CollectionChanged; |
|
47 | |
45 | |
|
48 | _mainForm.MemorySinkEnabled = false; |
46 | _mainForm.MemorySinkEnabled = false; |
|
49 | _memorySink.Clear(); |
47 | _memorySink.Clear(); |
|
50 | |
48 | |
|
51 | base.Dispose(disposing); |
49 | base.Dispose(disposing); |
|
52 | } |
50 | } |
|
53 | |
51 | |
|
54 | private void Events_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) |
52 | private void Events_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) |
|
55 | { |
53 | { |
|
56 | switch (e.Action) |
54 | switch (e.Action) |
|
57 | { |
55 | { |
|
58 | case NotifyCollectionChangedAction.Add: |
56 | case NotifyCollectionChangedAction.Add: |
|
59 | foreach (var item in e.NewItems) |
57 | foreach (var item in e.NewItems) |
|
60 | { |
58 | { |
|
61 | var line = (string)item; |
59 | var line = (string)item; |
|
62 | |
60 | |
|
63 | textBox1.InvokeIfRequired(textbox => { textbox.Text += line; }); |
61 | textBox1.InvokeIfRequired(textbox => { textbox.Text += line; }); |
|
64 | } |
62 | } |
|
65 | |
63 | |
|
66 | break; |
64 | break; |
|
67 | } |
65 | } |
|
68 | } |
66 | } |
|
- | 67 | |
||
- | 68 | private void LogViewForm_Load(object sender, System.EventArgs e) |
||
- | 69 | { |
||
- | 70 | Utilities.WindowState.FormTracker.Track(this); |
||
- | 71 | } |
||
69 | } |
72 | } |
|
70 | } |
73 | } |
|
71 | |
74 | |
|
72 |
|
75 |
|
|
73 | |
76 | |
|
74 | |
77 | |
|
75 | |
78 | |