/Horizon/Snapshots/SnapshotNoteForm.cs |
@@ -1,11 +1,6 @@ |
using System; |
using System.Security.Policy; |
using System.Threading; |
using System.Windows.Forms; |
using Horizon.Database; |
using Horizon.Utilities; |
using Serilog; |
using static System.Net.Mime.MediaTypeNames; |
|
namespace Horizon.Snapshots |
{ |
@@ -13,9 +8,7 @@ |
{ |
#region Private Delegates, Events, Enums, Properties, Indexers and Fields |
|
private readonly CancellationToken _cancellationToken; |
private readonly string _hash; |
private readonly SnapshotDatabase _snapshotDatabase; |
private readonly SnapshotManagerForm _snapshotManagerForm; |
|
#endregion |
|
@@ -30,13 +23,15 @@ |
public SnapshotNoteForm() |
{ |
InitializeComponent(); |
Utilities.WindowState.FormTracker.Track(this); |
} |
|
public SnapshotNoteForm(string hash, SnapshotDatabase snapshotDatabase, CancellationToken cancellationToken) : this() |
public SnapshotNoteForm(SnapshotManagerForm snapshotManagerForm, SnapshotPreview snapshotPreview) : this() |
{ |
_hash = hash; |
_snapshotDatabase = snapshotDatabase; |
_cancellationToken = cancellationToken; |
_snapshotManagerForm = snapshotManagerForm; |
_snapshotManagerForm.PreviewRetrieved += SnapshotManagerForm_PreviewRetrieved; |
|
richTextBox1.InvokeIfRequired(richTextBox => { richTextBox.Text = snapshotPreview.Note; }); |
} |
|
/// <summary> |
@@ -50,6 +45,8 @@ |
components.Dispose(); |
} |
|
_snapshotManagerForm.PreviewRetrieved -= SnapshotManagerForm_PreviewRetrieved; |
|
base.Dispose(disposing); |
} |
|
@@ -56,25 +53,10 @@ |
#endregion |
|
#region Event Handlers |
private async void SnapshotNoteForm_Load(object sender, EventArgs e) |
|
private void SnapshotManagerForm_PreviewRetrieved(object sender, PreviewRetrievedEventArgs e) |
{ |
Utilities.WindowState.FormTracker.Track(this); |
|
try |
{ |
var snapshotPreview = await _snapshotDatabase.RetrievePreviewAsync(_hash, _cancellationToken); |
|
if (snapshotPreview == null) |
{ |
return; |
} |
|
richTextBox1.InvokeIfRequired(richTextBox => { richTextBox.Text = snapshotPreview.Note; }); |
} |
catch (Exception exception) |
{ |
Log.Error(exception, "Unable to load note."); |
} |
richTextBox1.InvokeIfRequired(richTextBox => { richTextBox.Text = e.SnapshotPreview.Note; }); |
} |
|
private void Button1_Click(object sender, EventArgs e) |
@@ -91,7 +73,5 @@ |
} |
|
#endregion |
|
|
} |
} |