HamBook – Blame information for rev 59

Subversion Repositories:
Rev:
Rev Author Line No. Line
54 office 1 using System.Collections.Specialized;
1 office 2 using System.Threading;
3 using System.Windows.Forms;
54 office 4 using HamBook.Utilities;
1 office 5  
6 namespace HamBook
7 {
8 public partial class ViewLogsForm : Form
9 {
10 private readonly CancellationToken _cancellationToken;
11  
12 private readonly Form1 _mainForm;
13  
14 private readonly LogMemorySink _memorySink;
15  
16 public ViewLogsForm()
17 {
18 InitializeComponent();
19 }
20  
21 public ViewLogsForm(Form1 mainForm) : this()
22 {
23 _mainForm = mainForm;
24 _mainForm.MemorySinkEnabled = true;
25 }
26  
27 public ViewLogsForm(Form1 mainForm, LogMemorySink memorySink, CancellationToken cancellationToken) :
28 this(mainForm)
29 {
30 _memorySink = memorySink;
31 _memorySink.Events.CollectionChanged += Events_CollectionChanged;
32  
33 _cancellationToken = cancellationToken;
34 }
54 office 35  
1 office 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 {
54 office 42 if (disposing && components != null) components.Dispose();
1 office 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 }
59 office 67  
68 private void ViewLogsForm_Load(object sender, System.EventArgs e)
69 {
70 Utilities.WindowState.FormTracker.Track(this);
71 }
1 office 72 }
54 office 73 }