Horizon – Blame information for rev 4

Subversion Repositories:
Rev:
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 }
25  
26 public LogViewForm(MainForm mainForm, LogMemorySink memorySink, CancellationToken cancellationToken) :
27 this(mainForm)
28 {
29 _memorySink = memorySink;
30 _memorySink.Events.CollectionChanged += Events_CollectionChanged;
31  
32 _cancellationToken = cancellationToken;
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 _memorySink.Events.CollectionChanged -= Events_CollectionChanged;
47  
48 base.Dispose(disposing);
49 }
50  
51 private void Events_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
52 {
53 switch (e.Action)
54 {
55 case NotifyCollectionChangedAction.Add:
56 foreach (var item in e.NewItems)
57 {
58 var line = (string)item;
59  
60 textBox1.InvokeIfRequired(textbox => { textbox.AppendText(line); });
61 }
62  
63 break;
64 }
65 }
66  
67 private void LogViewForm_Load(object sender, System.EventArgs e)
68 {
69 Utilities.WindowState.FormTracker.Track(this);
4 office 70  
71 foreach(var @event in _memorySink.Events)
72 {
73 textBox1.AppendText(@event);
74 }
1 office 75 }
76 }
77 }