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