Winify – Blame information for rev 69

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();
19 }
20  
21 public LogViewForm(MainForm mainForm) : this()
22 {
23 _mainForm = mainForm;
24 _mainForm.MemorySinkEnabled = true;
25 }
26  
27 public LogViewForm(MainForm mainForm, LogMemorySink memorySink, CancellationToken cancellationToken) :
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 {
44 office 42 if (disposing && components != null) components.Dispose();
43 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.Text += line; });
62 }
63  
64 break;
65 }
66 }
69 office 67  
68 private void LogViewForm_Load(object sender, System.EventArgs e)
69 {
70 Utilities.WindowState.FormTracker.Track(this);
71 }
43 office 72 }
73 }