Horizon – Diff between revs 8 and 27

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