Zzz – Blame information for rev 2

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 using System.Collections.Specialized;
2 office 2 using System.Linq;
1 office 3 using System.Threading;
4 using System.Windows.Forms;
5 using Zzz.Utilities;
6  
7 namespace Zzz
8 {
9 public partial class LogViewForm : Form
10 {
2 office 11 private readonly CancellationToken _cancellationToken;
12  
1 office 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 }
26  
2 office 27 public LogViewForm(MainForm mainForm, LogMemorySink memorySink, CancellationToken cancellationToken) :
1 office 28 this(mainForm)
29 {
30 _memorySink = memorySink;
31 _memorySink.Events.CollectionChanged += Events_CollectionChanged;
2 office 32  
33 _cancellationToken = cancellationToken;
1 office 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 {
2 office 42 if (disposing && components != null) components.Dispose();
1 office 43  
2 office 44 _memorySink.Events.CollectionChanged -= Events_CollectionChanged;
1 office 45  
46 base.Dispose(disposing);
47 }
48  
49 private void Events_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
50 {
51 switch (e.Action)
52 {
53 case NotifyCollectionChangedAction.Add:
54 foreach (var item in e.NewItems)
55 {
56 var line = (string)item;
57  
58 textBox1.InvokeIfRequired(textbox => { textbox.AppendText(line); });
59 }
60  
61 break;
62 }
63 }
64  
65 private void LogViewForm_Load(object sender, System.EventArgs e)
66 {
67 Utilities.WindowState.FormTracker.Track(this);
2 office 68  
69 foreach (var @event in _memorySink.Events)
70 {
71 textBox1.AppendText(@event);
72 }
1 office 73 }
74 }
75 }