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