aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Integration/Storage/StorageFileHandler.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Tango.Integration/Storage/StorageFileHandler.cs')
-rw-r--r--Software/Visual_Studio/Tango.Integration/Storage/StorageFileHandler.cs74
1 files changed, 74 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Integration/Storage/StorageFileHandler.cs b/Software/Visual_Studio/Tango.Integration/Storage/StorageFileHandler.cs
new file mode 100644
index 000000000..72a4b2c87
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Integration/Storage/StorageFileHandler.cs
@@ -0,0 +1,74 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Core;
+
+namespace Tango.Integration.Storage
+{
+ public class StorageFileHandler : ExtendedObject
+ {
+ private Action _cancelAction;
+
+ public event EventHandler<StorageFileHandlerProgressEventArgs> Progress;
+ public event EventHandler Completed;
+ public event EventHandler Canceled;
+ public event EventHandler<Exception> Failed;
+
+ internal StorageFileHandler()
+ {
+
+ }
+
+ internal StorageFileHandler(Action cancelAction)
+ {
+ _cancelAction = cancelAction;
+ }
+
+ private long _current;
+ public long Current
+ {
+ get { return _current; }
+ internal set
+ {
+ _current = value; RaisePropertyChangedAuto();
+ Progress?.Invoke(this, new StorageFileHandlerProgressEventArgs()
+ {
+ Current = _current,
+ Total = _total,
+ });
+ }
+ }
+
+ private long _total;
+ public long Total
+ {
+ get { return _total; }
+ internal set { _total = value; RaisePropertyChangedAuto(); }
+ }
+
+ public Task Cancel()
+ {
+ return Task.Factory.StartNew(() =>
+ {
+ _cancelAction.Invoke();
+ });
+ }
+
+ internal void RaiseCompleted()
+ {
+ Completed?.Invoke(this, new EventArgs());
+ }
+
+ internal void RaiseCanceled()
+ {
+ Canceled?.Invoke(this, new EventArgs());
+ }
+
+ internal void RaiseFailed(Exception ex)
+ {
+ Failed?.Invoke(this, ex);
+ }
+ }
+}