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