Horizon

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 26  →  ?path2? @ 27
/Horizon/Snapshots/HexViewForm.cs
@@ -1,8 +1,12 @@
using System;
using System.Security.Policy;
using System.Threading;
using System.Windows.Forms;
using System.Windows.Markup;
using Be.Windows.Forms;
using Horizon.Database;
using Horizon.Utilities;
using Serilog;
 
namespace Horizon.Snapshots
{
@@ -35,11 +39,10 @@
private readonly SnapshotDatabase _snapshotDatabase;
 
private DynamicByteProvider _dynamicByteProvider;
 
private byte[] _originalData;
private string _hash;
private readonly CancellationToken _cancellationToken;
 
private byte[] _originalData;
 
#endregion
 
#region Constructors, Destructors and Finalizers
@@ -49,16 +52,12 @@
InitializeComponent();
}
 
public HexViewForm(SnapshotDatabase snapshotDatabase, string hash, byte[] data) : this()
public HexViewForm(string hash, SnapshotDatabase snapshotDatabase, CancellationToken cancellationToken) : this()
{
_originalData = (byte[])data.Clone();
_hash = hash;
 
_snapshotDatabase = snapshotDatabase;
_snapshotDatabase.SnapshotDataUpdate += SnapshotDatabaseSnapshotDataUpdate;
 
_dynamicByteProvider = new DynamicByteProvider(data);
hexBox1.ByteProvider = _dynamicByteProvider;
_cancellationToken = cancellationToken;
}
 
/// <summary>
@@ -80,9 +79,30 @@
#endregion
 
#region Event Handlers
private void HexViewForm_Load(object sender, EventArgs e)
private async void HexViewForm_Load(object sender, EventArgs e)
{
Utilities.WindowState.FormTracker.Track(this);
 
try
{
using var memoryStream = await _snapshotDatabase.RetrieveFileStreamAsync(_hash, _cancellationToken);
 
if (memoryStream == null)
{
return;
}
 
var data = memoryStream.ToArray();
 
_originalData = (byte[])data.Clone();
 
_dynamicByteProvider = new DynamicByteProvider(data);
hexBox1.ByteProvider = _dynamicByteProvider;
}
catch (Exception exception)
{
Log.Error(exception, "Could not retrieve snapshot data.");
}
}
private void SnapshotDatabaseSnapshotDataUpdate(object sender, SnapshotDataUpdateEventArgs e)
{
/Horizon/Snapshots/SnapshotManagerForm.cs
@@ -35,12 +35,6 @@
 
#endregion
 
#region Public Events & Delegates
 
public event EventHandler<PreviewRetrievedEventArgs> PreviewRetrieved;
 
#endregion
 
#region Private Delegates, Events, Enums, Properties, Indexers and Fields
 
private readonly MainForm _mainForm;
@@ -49,7 +43,7 @@
 
private HexViewForm _hexViewForm;
 
private SnapshotNoteForm _snapshotNote;
private SnapshotNoteForm _snapshotNoteForm;
 
private SnapshotPreviewForm _snapshotPreviewForm;
 
@@ -271,10 +265,10 @@
{
try
{
var fileStream = await _snapshotDatabase.RetrieveFileStreamAsync(
(string)rows[i].Cells["HashColumn"].Value,
cancellationToken);
var hash = (string)rows[i].Cells["HashColumn"].Value;
 
var fileStream = await _snapshotDatabase.RetrieveFileStreamAsync(hash, cancellationToken);
 
progress.Report(new DataGridViewRowProgressSuccessRetrieveFileStream(rows[i], i, fileStream));
}
catch (Exception exception)
@@ -286,7 +280,7 @@
 
private void SnapshotManagerForm_Resize(object sender, EventArgs e)
{
if (_snapshotPreviewForm != null)
if (_snapshotPreviewForm is { Visible: true })
{
_snapshotPreviewForm.WindowState = WindowState;
}
@@ -303,18 +297,10 @@
Process.Start("explorer.exe", $"/select, \"{(string)row.Cells["PathColumn"].Value}\"");
}
 
private async void DataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
private void DataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
var dataGridView = (DataGridView)sender;
 
if (_snapshotPreviewForm == null)
{
_snapshotPreviewForm = new SnapshotPreviewForm(this, _snapshotDatabase);
_snapshotPreviewForm.Owner = this;
_snapshotPreviewForm.Closing += SnapshotPreviewForm_Closing;
_snapshotPreviewForm.Show();
}
 
var row = GetSelectedDataGridViewRows(dataGridView).FirstOrDefault();
if (row == null)
{
@@ -323,27 +309,26 @@
 
var hash = (string)row.Cells["HashColumn"].Value;
 
var snapshotPreview =
await Task.Run(async () => await _snapshotDatabase.RetrievePreviewAsync(hash, _cancellationToken),
_cancellationToken);
 
if (snapshotPreview == null)
if (_snapshotPreviewForm is { Visible: true })
{
return;
_snapshotPreviewForm.Close();
}
 
PreviewRetrieved?.Invoke(this, new PreviewRetrievedEventArgs(snapshotPreview));
_snapshotPreviewForm = new SnapshotPreviewForm(this, hash, _snapshotDatabase, _cancellationToken);
_snapshotPreviewForm.Owner = this;
_snapshotPreviewForm.Closing += SnapshotPreviewForm_Closing;
_snapshotPreviewForm.Show();
}
 
private void SnapshotPreviewForm_Closing(object sender, CancelEventArgs e)
{
if (_snapshotPreviewForm == null)
if (_snapshotPreviewForm is { Visible: false })
{
return;
}
 
_snapshotPreviewForm.Closing -= SnapshotPreviewForm_Closing;
_snapshotPreviewForm.Dispose();
_snapshotPreviewForm = null;
}
 
private async void NoneToolStripMenuItem_Click(object sender, EventArgs e)
@@ -649,9 +634,25 @@
// Start browsing for network services.
_horizonServiceBrowser.Browse("_horizon._tcp", "local");
 
int count;
try
{
count = (int)await _snapshotDatabase.CountSnapshotsAsync(_cancellationToken);
}
catch (Exception exception)
{
Log.Error(exception, "Could not count snapshots.");
return;
}
 
if (count == 0)
{
return;
}
 
// Load snapshots.
toolStripProgressBar1.Minimum = 0;
toolStripProgressBar1.Maximum = (int)await _snapshotDatabase.CountSnapshotsAsync(_cancellationToken);
toolStripProgressBar1.Maximum = count;
 
var snapshotQueue = new ConcurrentQueue<Snapshot>();
 
@@ -791,16 +792,14 @@
{
_cancellationTokenSource.Cancel();
 
if (_snapshotPreviewForm != null)
if (_snapshotPreviewForm is { Visible: true })
{
_snapshotPreviewForm.Close();
_snapshotPreviewForm = null;
}
 
if (_hexViewForm != null)
if (_hexViewForm is { Visible: true })
{
_hexViewForm.Close();
_hexViewForm = null;
}
}
 
@@ -835,8 +834,7 @@
 
try
{
await _snapshotDatabase.CreateSnapshotAsync(name, path, screenCapture, color,
_cancellationToken);
await _snapshotDatabase.CreateSnapshotAsync(name, path, screenCapture, color, _cancellationToken);
 
progress.Report(new CreateSnapshotProgressSuccess(file));
}
@@ -850,6 +848,7 @@
}
 
var fileName = Path.GetFileName(file);
 
var pathName = Path.Combine(Path.GetDirectoryName(file), fileName);
 
try
@@ -1044,13 +1043,8 @@
}
}
 
private async void NoteToolStripMenuItem_Click(object sender, EventArgs e)
private void NoteToolStripMenuItem_Click(object sender, EventArgs e)
{
if (_snapshotNote != null)
{
return;
}
 
var row = GetSelectedDataGridViewRows(dataGridView1).FirstOrDefault();
if (row == null)
{
@@ -1057,29 +1051,21 @@
return;
}
 
try
{
var snapshotPreview = await _snapshotDatabase.RetrievePreviewAsync(
(string)row.Cells["HashColumn"].Value, _cancellationToken);
var hash = (string)row.Cells["HashColumn"].Value;
 
if (snapshotPreview == null)
{
return;
}
 
_snapshotNote = new SnapshotNoteForm(this, snapshotPreview);
_snapshotNote.Owner = this;
_snapshotNote.SaveNote += SnapshotNote_SaveNote;
_snapshotNote.Closing += SnapshotNote_Closing;
_snapshotNote.Show();
}
catch (Exception exception)
if (_snapshotNoteForm is { Visible: true })
{
Log.Error(exception, "Could not open notes form.");
_snapshotNoteForm.Close();
}
 
_snapshotNoteForm = new SnapshotNoteForm(hash, _snapshotDatabase, _cancellationToken);
_snapshotNoteForm.Owner = this;
_snapshotNoteForm.SaveNote += SnapshotNoteFormSaveNoteForm;
_snapshotNoteForm.Closing += SnapshotNoteForm_Closing;
_snapshotNoteForm.Show();
}
 
private async void SnapshotNote_SaveNote(object sender, SaveNoteEventArgs e)
private async void SnapshotNoteFormSaveNoteForm(object sender, SaveNoteEventArgs e)
{
var rows = GetSelectedDataGridViewRows(dataGridView1);
 
@@ -1119,19 +1105,19 @@
}
}
 
private void SnapshotNote_Closing(object sender, CancelEventArgs e)
private void SnapshotNoteForm_Closing(object sender, CancelEventArgs e)
{
if (_snapshotNote == null)
if (_snapshotNoteForm is { Visible: false })
{
return;
}
 
_snapshotNote.Closing -= SnapshotNote_Closing;
_snapshotNote.Close();
_snapshotNote = null;
_snapshotNoteForm.SaveNote -= SnapshotNoteFormSaveNoteForm;
_snapshotNoteForm.Closing -= SnapshotNoteForm_Closing;
_snapshotNoteForm.Dispose();
}
 
private async void ViewHexToolStripMenuItem_Click(object sender, EventArgs e)
private void ViewHexToolStripMenuItem_Click(object sender, EventArgs e)
{
var rows = GetSelectedDataGridViewRows(dataGridView1);
var row = rows.FirstOrDefault();
@@ -1142,33 +1128,32 @@
 
var hash = (string)row.Cells["HashColumn"].Value;
 
using (var memoryStream = await _snapshotDatabase.RetrieveFileStreamAsync(hash, _cancellationToken))
if (_hexViewForm is { Visible: true })
{
if (memoryStream == null)
{
return;
}
_hexViewForm.Close();
}
 
if (_hexViewForm != null)
{
_hexViewForm.UpdateData(memoryStream.ToArray());
_hexViewForm.Activate();
return;
}
 
_hexViewForm = new HexViewForm(_snapshotDatabase, hash, memoryStream.ToArray());
_hexViewForm.Owner = this;
_hexViewForm.Closing += HexViewForm_Closing;
_hexViewForm.SaveData += HexViewForm_SaveData;
 
_hexViewForm.Show();
}
_hexViewForm = new HexViewForm(hash, _snapshotDatabase, _cancellationToken);
_hexViewForm.Owner = this;
_hexViewForm.Closing += HexViewForm_Closing;
_hexViewForm.SaveData += HexViewForm_SaveData;
_hexViewForm.Show();
}
 
private async void HexViewForm_SaveData(object sender, SaveDataEventArgs e)
{
var hash = await _snapshotDatabase.UpdateFileAsync(e.Hash, e.Data, _cancellationToken);
string hash;
 
try
{
hash = await _snapshotDatabase.UpdateFileAsync(e.Hash, e.Data, _cancellationToken);
}
catch (Exception exception)
{
Log.Error(exception, "Could not update snapshot data.");
return;
}
 
if (string.IsNullOrEmpty(hash))
{
return;
@@ -1203,7 +1188,7 @@
 
private void HexViewForm_Closing(object sender, CancelEventArgs e)
{
if (_hexViewForm == null)
if (_hexViewForm is { Visible: false })
{
return;
}
@@ -1210,8 +1195,7 @@
 
_hexViewForm.SaveData -= HexViewForm_SaveData;
_hexViewForm.Closing -= HexViewForm_Closing;
_hexViewForm.Close();
_hexViewForm = null;
_hexViewForm.Dispose();
}
 
private async void FileToolStripMenuItem2_Click(object sender, EventArgs e)
@@ -1492,9 +1476,10 @@
{
try
{
await _snapshotDatabase.RemoveFileAsync((string)rows[index].Cells["HashColumn"].Value,
cancellationToken);
var hash = (string)rows[index].Cells["HashColumn"].Value;
 
await _snapshotDatabase.RemoveFileAsync(hash, cancellationToken);
 
progress.Report(new DataGridViewRowProgressSuccess(rows[index], index));
}
catch (Exception exception)
@@ -1508,7 +1493,14 @@
{
var hashes = rows.Select(row => (string)row.Cells["HashColumn"].Value);
 
await _snapshotDatabase.RemoveFileFastAsync(hashes, cancellationToken);
try
{
await _snapshotDatabase.RemoveFileFastAsync(hashes, cancellationToken);
}
catch (Exception exception)
{
Log.Error(exception, "Failed to remove files.");
}
}
 
private async Task UpdateNote(IReadOnlyList<DataGridViewRow> rows, string note,
@@ -1520,9 +1512,10 @@
{
try
{
await _snapshotDatabase.UpdateNoteAsync((string)rows[i].Cells["HashColumn"].Value, note,
cancellationToken);
var hash = (string)rows[i].Cells["HashColumn"].Value;
 
await _snapshotDatabase.UpdateNoteAsync(hash, note,cancellationToken);
 
progress.Report(new DataGridViewRowProgressSuccess(rows[i], i));
}
catch (Exception exception)
@@ -1552,9 +1545,10 @@
{
try
{
await _snapshotDatabase.RemoveColorAsync((string)rows[i].Cells["HashColumn"].Value,
cancellationToken);
var hash = (string)rows[i].Cells["HashColumn"].Value;
 
await _snapshotDatabase.RemoveColorAsync(hash, cancellationToken);
 
progress.Report(new DataGridViewRowProgressSuccess(rows[i], i));
}
catch (Exception exception)
@@ -1573,9 +1567,10 @@
{
try
{
await _snapshotDatabase.UpdateColorAsync((string)rows[i].Cells["HashColumn"].Value, color,
cancellationToken);
var hash = (string)rows[i].Cells["HashColumn"].Value;
 
await _snapshotDatabase.UpdateColorAsync(hash, color, cancellationToken);
 
progress.Report(new DataGridViewRowProgressSuccess(rows[i], i));
}
catch (Exception exception)
@@ -1605,9 +1600,10 @@
{
try
{
var hash = (string)rows[i].Cells["HashColumn"].Value;
 
var completeSnapshot =
await _snapshotDatabase.GenerateTransferSnapshotAsync(
(string)rows[i].Cells["HashColumn"].Value, cancellationToken);
await _snapshotDatabase.GenerateTransferSnapshotAsync(hash, cancellationToken);
 
var jsonSnapshot = JsonConvert.SerializeObject(completeSnapshot);
 
@@ -1666,10 +1662,11 @@
{
try
{
await _snapshotDatabase.RevertFileAsync((string)rows[i].Cells["NameColumn"].Value,
(string)rows[i].Cells["HashColumn"].Value,
cancellationToken, _mainForm.Configuration.AtomicOperations);
var path = (string)rows[i].Cells["NameColumn"].Value;
var hash = (string)rows[i].Cells["HashColumn"].Value;
 
await _snapshotDatabase.RevertFileAsync(path, hash, cancellationToken, _mainForm.Configuration.AtomicOperations);
 
progress.Report(new DataGridViewRowProgressSuccess(rows[i], i));
}
catch (Exception exception)
@@ -1688,12 +1685,12 @@
{
try
{
var hash = (string)rows[i].Cells["HashColumn"].Value;
var fileInfo = new FileInfo((string)rows[i].Cells["NameColumn"].Value);
var file = fileInfo.Name;
var path = Path.Combine(directory, file);
 
await _snapshotDatabase.SaveFileAsync(path, (string)rows[i].Cells["HashColumn"].Value,
cancellationToken);
await _snapshotDatabase.SaveFileAsync(path, hash, cancellationToken);
 
progress.Report(new DataGridViewRowProgressSuccess(rows[i], i));
}
@@ -1714,10 +1711,10 @@
{
try
{
var hash = (string)rows[i].Cells["HashColumn"].Value;
var path = Path.Combine(directory, (string)rows[i].Cells["NameColumn"].Value);
 
await _snapshotDatabase.RelocateFileAsync((string)rows[i].Cells["HashColumn"].Value, path,
cancellationToken);
await _snapshotDatabase.RelocateFileAsync(hash, path, cancellationToken);
 
progress.Report(new DataGridViewRowProgressSuccess(rows[i], i));
}
@@ -1738,29 +1735,26 @@
{
try
{
using (var memoryStream =
await _snapshotDatabase.RetrieveFileStreamAsync((string)rows[i].Cells["HashColumn"].Value,
cancellationToken))
var hash = (string)rows[i].Cells["HashColumn"].Value;
 
using var memoryStream = await _snapshotDatabase.RetrieveFileStreamAsync(hash, cancellationToken);
if (memoryStream == null)
{
if (memoryStream == null)
{
continue;
}
continue;
}
 
using (var md5 = MD5.Create())
{
var recomputedHash = md5.ComputeHash(memoryStream);
var hashHex = BitConverter.ToString(recomputedHash).Replace("-", "")
.ToLowerInvariant();
using var md5 = MD5.Create();
 
await _snapshotDatabase.UpdateHashAsync((string)rows[i].Cells["HashColumn"].Value, hashHex,
cancellationToken);
var recomputedHash = md5.ComputeHash(memoryStream);
var hashHex = BitConverter.ToString(recomputedHash).Replace("-", "")
.ToLowerInvariant();
await _snapshotDatabase.UpdateHashAsync(hash, hashHex,
cancellationToken);
 
rows[i].Cells["HashColumn"].Value = hashHex;
rows[i].Cells["HashColumn"].Value = hashHex;
 
progress.Report(new DataGridViewRowProgressSuccess(rows[i], i));
}
}
progress.Report(new DataGridViewRowProgressSuccess(rows[i], i));
}
catch (Exception exception)
{
@@ -1800,6 +1794,7 @@
var newPath = Path.Combine(targetPath, rootPath, relPath);
 
var hash = (string)rows[i].Cells["HashColumn"].Value;
 
await _snapshotDatabase.SaveFileAsync(newPath, hash, cancellationToken);
 
progress.Report(new DataGridViewRowProgressSuccess(rows[i], i));
@@ -1826,9 +1821,10 @@
{
try
{
await _snapshotDatabase.NormalizeTimeAsync((string)rows[i].Cells["HashColumn"].Value,
cancellationToken);
var hash = (string)rows[i].Cells["HashColumn"].Value;
 
await _snapshotDatabase.NormalizeTimeAsync(hash, cancellationToken);
 
progress.Report(new DataGridViewRowProgressSuccess(rows[i], i));
}
catch (Exception exception)
@@ -1890,9 +1886,10 @@
{
try
{
await _snapshotDatabase.DeleteScreenshotAsync((string)rows[i].Cells["HashColumn"].Value,
cancellationToken);
var hash = (string)rows[i].Cells["HashColumn"].Value;
 
await _snapshotDatabase.DeleteScreenshotAsync(hash, cancellationToken);
 
progress.Report(new DataGridViewRowProgressSuccess(rows[i], i));
}
catch (Exception exception)
/Horizon/Snapshots/SnapshotNoteForm.cs
@@ -1,6 +1,11 @@
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
{
@@ -8,7 +13,9 @@
{
#region Private Delegates, Events, Enums, Properties, Indexers and Fields
 
private readonly SnapshotManagerForm _snapshotManagerForm;
private readonly CancellationToken _cancellationToken;
private readonly string _hash;
private readonly SnapshotDatabase _snapshotDatabase;
 
#endregion
 
@@ -25,12 +32,11 @@
InitializeComponent();
}
 
public SnapshotNoteForm(SnapshotManagerForm snapshotManagerForm, SnapshotPreview snapshotPreview) : this()
public SnapshotNoteForm(string hash, SnapshotDatabase snapshotDatabase, CancellationToken cancellationToken) : this()
{
_snapshotManagerForm = snapshotManagerForm;
_snapshotManagerForm.PreviewRetrieved += SnapshotManagerForm_PreviewRetrieved;
 
richTextBox1.InvokeIfRequired(richTextBox => { richTextBox.Text = snapshotPreview.Note; });
_hash = hash;
_snapshotDatabase = snapshotDatabase;
_cancellationToken = cancellationToken;
}
 
/// <summary>
@@ -44,8 +50,6 @@
components.Dispose();
}
 
_snapshotManagerForm.PreviewRetrieved -= SnapshotManagerForm_PreviewRetrieved;
 
base.Dispose(disposing);
}
 
@@ -52,14 +56,26 @@
#endregion
 
#region Event Handlers
private void SnapshotNoteForm_Load(object sender, EventArgs e)
private async void SnapshotNoteForm_Load(object sender, EventArgs 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.");
}
}
private void SnapshotManagerForm_PreviewRetrieved(object sender, PreviewRetrievedEventArgs e)
{
richTextBox1.InvokeIfRequired(richTextBox => { richTextBox.Text = e.SnapshotPreview.Note; });
}
 
private void Button1_Click(object sender, EventArgs e)
{
/Horizon/Snapshots/SnapshotPreviewForm.cs
@@ -1,8 +1,11 @@
using System;
using System.Drawing;
using System.Security.Policy;
using System.Threading;
using System.Windows.Forms;
using Horizon.Database;
using Horizon.Utilities;
using Serilog;
 
namespace Horizon.Snapshots
{
@@ -27,6 +30,8 @@
private readonly SnapshotDatabase _snapshotDatabase;
 
private readonly SnapshotManagerForm _snapshotManagerForm;
private readonly string _snapshotHash;
private readonly CancellationToken _cancellationToken;
 
#endregion
 
@@ -38,16 +43,18 @@
Utilities.WindowState.FormTracker.Track(this);
}
 
public SnapshotPreviewForm(SnapshotManagerForm snapshotManagerForm, SnapshotDatabase snapshotDatabase) : this()
public SnapshotPreviewForm(SnapshotManagerForm snapshotManagerForm, string hash,
SnapshotDatabase snapshotDatabase, CancellationToken cancellationToken) : this()
{
_snapshotManagerForm = snapshotManagerForm;
_snapshotHash = hash;
_snapshotManagerForm.Move += SnapshotManagerFormMove;
_snapshotManagerForm.Resize += SnapshotManagerFormResize;
_snapshotManagerForm.PreviewRetrieved += SnapshotManagerForm_PreviewRetrieved;
;
 
_snapshotDatabase = snapshotDatabase;
_snapshotDatabase.SnapshotNoteUpdate += SnapshotDatabase_SnapshotNoteUpdate;
 
_cancellationToken = cancellationToken;
}
 
/// <summary>
@@ -62,7 +69,6 @@
}
 
_snapshotDatabase.SnapshotNoteUpdate -= SnapshotDatabase_SnapshotNoteUpdate;
_snapshotManagerForm.PreviewRetrieved -= SnapshotManagerForm_PreviewRetrieved;
 
_snapshotManagerForm.Move -= SnapshotManagerFormMove;
_snapshotManagerForm.Resize -= SnapshotManagerFormResize;
@@ -74,23 +80,7 @@
 
#region Event Handlers
 
private void SnapshotManagerForm_PreviewRetrieved(object sender, PreviewRetrievedEventArgs e)
{
using (var image = pictureBox1.Image)
{
pictureBox1.Image = e.SnapshotPreview.Shot;
richTextBox1.Text = e.SnapshotPreview.Note;
}
 
if (string.IsNullOrEmpty(e.SnapshotPreview.Note))
{
splitContainer1.Panel2Collapsed = true;
return;
}
 
splitContainer1.Panel2Collapsed = false;
}
 
private void SnapshotDatabase_SnapshotNoteUpdate(object sender, SnapshotNoteUpdateEventArgs e)
{
switch (e)
@@ -123,9 +113,40 @@
Relocate();
}
 
private void SnapshotPreviewForm_Load(object sender, EventArgs e)
private async void SnapshotPreviewForm_Load(object sender, EventArgs e)
{
Relocate();
 
try
{
var snapshotPreview = await _snapshotDatabase.RetrievePreviewAsync(_snapshotHash, _cancellationToken);
 
if (snapshotPreview == null)
{
return;
}
 
this.InvokeIfRequired(form =>
{
using (var image = form.pictureBox1.Image)
{
form.pictureBox1.Image = snapshotPreview.Shot;
form.richTextBox1.Text = snapshotPreview.Note;
}
 
if (string.IsNullOrEmpty(snapshotPreview.Note))
{
form.splitContainer1.Panel2Collapsed = true;
return;
}
 
form.splitContainer1.Panel2Collapsed = false;
});
}
catch (Exception exception)
{
Log.Error(exception, "Could not retrieve preview.");
}
}
 
private void SnapshotManagerFormMove(object sender, EventArgs e)