Horizon – Blame information for rev 27

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 using System;
27 office 2 using System.Security.Policy;
3 using System.Threading;
1 office 4 using System.Windows.Forms;
27 office 5 using Horizon.Database;
1 office 6 using Horizon.Utilities;
27 office 7 using Serilog;
8 using static System.Net.Mime.MediaTypeNames;
1 office 9  
10 namespace Horizon.Snapshots
11 {
12 public partial class SnapshotNoteForm : Form
13 {
14 #region Private Delegates, Events, Enums, Properties, Indexers and Fields
15  
27 office 16 private readonly CancellationToken _cancellationToken;
17 private readonly string _hash;
18 private readonly SnapshotDatabase _snapshotDatabase;
1 office 19  
20 #endregion
21  
22 #region Public Events & Delegates
23  
24 public event EventHandler<SaveNoteEventArgs> SaveNote;
25  
26 #endregion
27  
28 #region Constructors, Destructors and Finalizers
29  
30 public SnapshotNoteForm()
31 {
32 InitializeComponent();
33 }
34  
27 office 35 public SnapshotNoteForm(string hash, SnapshotDatabase snapshotDatabase, CancellationToken cancellationToken) : this()
1 office 36 {
27 office 37 _hash = hash;
38 _snapshotDatabase = snapshotDatabase;
39 _cancellationToken = cancellationToken;
1 office 40 }
41  
42 /// <summary>
43 /// Clean up any resources being used.
44 /// </summary>
45 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
46 protected override void Dispose(bool disposing)
47 {
48 if (disposing && components != null)
49 {
50 components.Dispose();
51 }
52  
53 base.Dispose(disposing);
54 }
55  
56 #endregion
57  
58 #region Event Handlers
27 office 59 private async void SnapshotNoteForm_Load(object sender, EventArgs e)
8 office 60 {
61 Utilities.WindowState.FormTracker.Track(this);
27 office 62  
63 try
64 {
65 var snapshotPreview = await _snapshotDatabase.RetrievePreviewAsync(_hash, _cancellationToken);
66  
67 if (snapshotPreview == null)
68 {
69 return;
70 }
71  
72 richTextBox1.InvokeIfRequired(richTextBox => { richTextBox.Text = snapshotPreview.Note; });
73 }
74 catch (Exception exception)
75 {
76 Log.Error(exception, "Unable to load note.");
77 }
8 office 78 }
1 office 79  
80 private void Button1_Click(object sender, EventArgs e)
81 {
82 richTextBox1.InvokeIfRequired(richTextBox =>
83 {
84 SaveNote?.Invoke(this, new SaveNoteEventArgs(richTextBox.Text));
85 });
86 }
87  
88 private void Button2_Click(object sender, EventArgs e)
89 {
90 Close();
91 }
92  
93 #endregion
8 office 94  
95  
1 office 96 }
97 }