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