QuickImage – Blame information for rev 8

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 QuickImage.Utilities;
5  
6 namespace QuickImage
7 {
8 public partial class ViewLogsForm : Form
9 {
10 private readonly CancellationToken _cancellationToken;
11  
7 office 12 private readonly Form1 _mainForm;
1 office 13  
14 private readonly LogMemorySink _memorySink;
15  
16 public ViewLogsForm()
17 {
18 InitializeComponent();
19 }
20  
7 office 21 public ViewLogsForm(Form1 mainForm) : this()
1 office 22 {
23 _mainForm = mainForm;
24 }
25  
7 office 26 public ViewLogsForm(Form1 mainForm, LogMemorySink memorySink, CancellationToken cancellationToken) :
1 office 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) components.Dispose();
42  
43 _memorySink.Events.CollectionChanged -= Events_CollectionChanged;
44  
45 base.Dispose(disposing);
46 }
47  
48 private void Events_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
49 {
50 switch (e.Action)
51 {
52 case NotifyCollectionChangedAction.Add:
53 foreach (var item in e.NewItems)
54 {
55 var line = (string)item;
56  
57 textBox1.InvokeIfRequired(textbox => { textbox.AppendText(line); });
58 }
59  
60 break;
61 }
62 }
63  
64 private void ViewLogsForm_Load(object sender, System.EventArgs e)
65 {
8 office 66 JotFormTracker.Tracker.Track(this);
67  
68  
69 foreach (var @event in _memorySink.Events)
70 {
71 textBox1.AppendText(@event);
72 }
1 office 73 }
74 }
75 }