QuickImage – Blame information for rev 5

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  
5 office 12 private readonly QuickImage _mainForm;
1 office 13  
14 private readonly LogMemorySink _memorySink;
15  
16 public ViewLogsForm()
17 {
18 InitializeComponent();
19 }
20  
5 office 21 public ViewLogsForm(QuickImage mainForm) : this()
1 office 22 {
23 _mainForm = mainForm;
24 _mainForm.MemorySinkEnabled = true;
25 }
26  
5 office 27 public ViewLogsForm(QuickImage mainForm, LogMemorySink memorySink, CancellationToken cancellationToken) :
1 office 28 this(mainForm)
29 {
30 _memorySink = memorySink;
31 _memorySink.Events.CollectionChanged += Events_CollectionChanged;
32  
33 _cancellationToken = cancellationToken;
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 {
42 if (disposing && components != null) components.Dispose();
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 }
67  
68 private void ViewLogsForm_Load(object sender, System.EventArgs e)
69 {
70 JotFormTracker.Tracker.Track(this);
71 }
72 }
73 }