Horizon – Diff between revs 8 and 27
?pathlinks?
Rev 8 | Rev 27 | |||
---|---|---|---|---|
Line 1... | Line 1... | |||
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; |
||
Line 4... | Line 9... | |||
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 | { |
|
Line -... | Line 14... | |||
- | 14 | #region Private Delegates, Events, Enums, Properties, Indexers and Fields |
||
- | 15 | |
||
9 | #region Private Delegates, Events, Enums, Properties, Indexers and Fields |
16 | private readonly CancellationToken _cancellationToken; |
|
Line 10... | Line 17... | |||
10 | |
17 | private readonly string _hash; |
|
Line 11... | Line 18... | |||
11 | private readonly SnapshotManagerForm _snapshotManagerForm; |
18 | private readonly SnapshotDatabase _snapshotDatabase; |
|
Line 23... | Line 30... | |||
23 | public SnapshotNoteForm() |
30 | public SnapshotNoteForm() |
|
24 | { |
31 | { |
|
25 | InitializeComponent(); |
32 | InitializeComponent(); |
|
26 | } |
33 | } |
|
Line 27... | Line 34... | |||
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; |
|
Line 34... | Line 40... | |||
34 | } |
40 | } |
|
35 | |
41 | |
|
36 | /// <summary> |
42 | /// <summary> |
|
Line 42... | Line 48... | |||
42 | if (disposing && components != null) |
48 | if (disposing && components != null) |
|
43 | { |
49 | { |
|
44 | components.Dispose(); |
50 | components.Dispose(); |
|
45 | } |
51 | } |
|
Line 46... | Line -... | |||
46 | |
- | ||
47 | _snapshotManagerForm.PreviewRetrieved -= SnapshotManagerForm_PreviewRetrieved; |
- | ||
48 | |
52 | |
|
49 | base.Dispose(disposing); |
53 | base.Dispose(disposing); |
|
Line 50... | Line 54... | |||
50 | } |
54 | } |
|
Line 51... | Line 55... | |||
51 | |
55 | |
|
52 | #endregion |
56 | #endregion |
|
53 | |
57 | |
|
54 | #region Event Handlers |
58 | #region Event Handlers |
|
- | 59 | private async void SnapshotNoteForm_Load(object sender, EventArgs e) |
||
- | 60 | { |
||
- | 61 | Utilities.WindowState.FormTracker.Track(this); |
||
- | 62 | |
||
- | 63 | try |
||
- | 64 | { |
||
- | 65 | var snapshotPreview = await _snapshotDatabase.RetrievePreviewAsync(_hash, _cancellationToken); |
||
- | 66 | |
||
55 | private void SnapshotNoteForm_Load(object sender, EventArgs e) |
67 | if (snapshotPreview == null) |
|
- | 68 | { |
||
56 | { |
69 | return; |
|
- | 70 | } |
||
- | 71 | |
||
57 | Utilities.WindowState.FormTracker.Track(this); |
72 | richTextBox1.InvokeIfRequired(richTextBox => { richTextBox.Text = snapshotPreview.Note; }); |
|
58 | } |
73 | } |
|
- | 74 | catch (Exception exception) |
||
59 | private void SnapshotManagerForm_PreviewRetrieved(object sender, PreviewRetrievedEventArgs e) |
75 | { |
|
Line 60... | Line 76... | |||
60 | { |
76 | Log.Error(exception, "Unable to load note."); |
|
61 | richTextBox1.InvokeIfRequired(richTextBox => { richTextBox.Text = e.SnapshotPreview.Note; }); |
77 | } |
|
62 | } |
78 | } |