Horizon – Diff between revs 8 and 27

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
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 System.Windows.Markup;
3 using Be.Windows.Forms; 6 using Be.Windows.Forms;
4 using Horizon.Database; 7 using Horizon.Database;
5 using Horizon.Utilities; 8 using Horizon.Utilities;
-   9 using Serilog;
Line 6... Line 10...
6   10  
7 namespace Horizon.Snapshots 11 namespace Horizon.Snapshots
8 { 12 {
9 public partial class HexViewForm : Form 13 public partial class HexViewForm : Form
Line 33... Line 37...
33 #region Private Delegates, Events, Enums, Properties, Indexers and Fields 37 #region Private Delegates, Events, Enums, Properties, Indexers and Fields
Line 34... Line 38...
34   38  
Line 35... Line 39...
35 private readonly SnapshotDatabase _snapshotDatabase; 39 private readonly SnapshotDatabase _snapshotDatabase;
36   -  
37 private DynamicByteProvider _dynamicByteProvider; -  
38   -  
39 private string _hash; 40  
-   41 private DynamicByteProvider _dynamicByteProvider;
-   42 private byte[] _originalData;
Line 40... Line 43...
40   43 private string _hash;
Line 41... Line 44...
41 private byte[] _originalData; 44 private readonly CancellationToken _cancellationToken;
Line 42... Line 45...
42   45  
43 #endregion 46 #endregion
44   47  
45 #region Constructors, Destructors and Finalizers 48 #region Constructors, Destructors and Finalizers
Line 46... Line 49...
46   49  
47 public HexViewForm() 50 public HexViewForm()
48 { -  
49 InitializeComponent(); 51 {
50 } -  
51   52 InitializeComponent();
52 public HexViewForm(SnapshotDatabase snapshotDatabase, string hash, byte[] data) : this() 53 }
53 { -  
54 _originalData = (byte[])data.Clone(); -  
55 _hash = hash; 54  
56   55 public HexViewForm(string hash, SnapshotDatabase snapshotDatabase, CancellationToken cancellationToken) : this()
Line 57... Line 56...
57 _snapshotDatabase = snapshotDatabase; 56 {
58 _snapshotDatabase.SnapshotDataUpdate += SnapshotDatabaseSnapshotDataUpdate; 57 _hash = hash;
59   58 _snapshotDatabase = snapshotDatabase;
Line 78... Line 77...
78 } 77 }
Line 79... Line 78...
79   78  
Line 80... Line 79...
80 #endregion 79 #endregion
81   80  
82 #region Event Handlers 81 #region Event Handlers
83 private void HexViewForm_Load(object sender, EventArgs e) 82 private async void HexViewForm_Load(object sender, EventArgs e)
-   83 {
-   84 Utilities.WindowState.FormTracker.Track(this);
-   85  
-   86 try
-   87 {
-   88 using var memoryStream = await _snapshotDatabase.RetrieveFileStreamAsync(_hash, _cancellationToken);
-   89  
-   90 if (memoryStream == null)
-   91 {
-   92 return;
-   93 }
-   94  
-   95 var data = memoryStream.ToArray();
-   96  
-   97 _originalData = (byte[])data.Clone();
-   98  
-   99 _dynamicByteProvider = new DynamicByteProvider(data);
-   100 hexBox1.ByteProvider = _dynamicByteProvider;
-   101 }
-   102 catch (Exception exception)
-   103 {
84 { 104 Log.Error(exception, "Could not retrieve snapshot data.");
85 Utilities.WindowState.FormTracker.Track(this); 105 }
86 } 106 }
87 private void SnapshotDatabaseSnapshotDataUpdate(object sender, SnapshotDataUpdateEventArgs e) 107 private void SnapshotDatabaseSnapshotDataUpdate(object sender, SnapshotDataUpdateEventArgs e)
88 { 108 {