Winify – Blame information for rev 44

Subversion Repositories:
Rev:
Rev Author Line No. Line
43 office 1 using System.Collections.Specialized;
2 using System.Threading;
3 using System.Windows.Forms;
4 using Winify.Utilities;
5  
6 namespace Winify
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();
44 office 19  
20 Utilities.WindowState.FormTracker.Track(this);
43 office 21 }
22  
23 public LogViewForm(MainForm mainForm) : this()
24 {
25 _mainForm = mainForm;
26 _mainForm.MemorySinkEnabled = true;
27 }
28  
29 public LogViewForm(MainForm mainForm, LogMemorySink memorySink, CancellationToken cancellationToken) :
30 this(mainForm)
31 {
32 _memorySink = memorySink;
33 _memorySink.Events.CollectionChanged += Events_CollectionChanged;
34  
35 _cancellationToken = cancellationToken;
36 }
37  
38 /// <summary>
39 /// Clean up any resources being used.
40 /// </summary>
41 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
42 protected override void Dispose(bool disposing)
43 {
44 office 44 if (disposing && components != null) components.Dispose();
43 office 45  
46 _memorySink.Events.CollectionChanged -= Events_CollectionChanged;
47  
48 _mainForm.MemorySinkEnabled = false;
49 _memorySink.Clear();
50  
51 base.Dispose(disposing);
52 }
53  
54 private void Events_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
55 {
56 switch (e.Action)
57 {
58 case NotifyCollectionChangedAction.Add:
59 foreach (var item in e.NewItems)
60 {
61 var line = (string)item;
62  
63 textBox1.InvokeIfRequired(textbox => { textbox.Text += line; });
64 }
65  
66 break;
67 }
68 }
69 }
70 }