From d37bc3c65acb6ab3e265c3d1560ed54f1693249d Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Tue, 14 Apr 2020 20:25:47 +0300 Subject: FSE TUP/TFP. Refactored progress with TangoProgress --- .../FileSystem/FileSystemHandler.cs | 37 +++++++++++----------- 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'Software/Visual_Studio/FSE/Tango.FSE.Common/FileSystem/FileSystemHandler.cs') diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/FileSystem/FileSystemHandler.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/FileSystem/FileSystemHandler.cs index 9cceb4fa3..b1f4446d2 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/FileSystem/FileSystemHandler.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/FileSystem/FileSystemHandler.cs @@ -17,6 +17,7 @@ namespace Tango.FSE.Common.FileSystem private TaskCompletionSource _completionSource; public event EventHandler StatusChanged; + public event EventHandler> ProgressChanged; public FileSystemHandlerType Type { get; set; } @@ -35,6 +36,13 @@ namespace Tango.FSE.Common.FileSystem } } + private TangoProgress _progress; + public TangoProgress Progress + { + get { return _progress; } + set { _progress = value; RaisePropertyChangedAuto(); } + } + private bool _isPaused; public bool IsPaused { @@ -60,20 +68,6 @@ namespace Tango.FSE.Common.FileSystem } } - private double _position; - public double Position - { - get { return _position; } - set { _position = value; RaisePropertyChangedAuto(); } - } - - private double _length; - public double Length - { - get { return _length; } - set { _length = value; RaisePropertyChangedAuto(); } - } - private long _transferRate; public long TransferRate { @@ -94,6 +88,7 @@ namespace Tango.FSE.Common.FileSystem public FileSystemHandler(FileSystemHandlerType type, FileSystemItem fileSystemItem, String destination, Action abortAction) { + Progress = new TangoProgress(); _completionSource = new TaskCompletionSource(); Type = type; FileSystemItem = fileSystemItem; @@ -109,8 +104,8 @@ namespace Tango.FSE.Common.FileSystem return; } - TransferRate = (long)(Position - _lastPosition); - _lastPosition = Position; + TransferRate = (long)(Progress.Value - _lastPosition); + _lastPosition = Progress.Value; } internal void InvalidateProgress(double position, double length) @@ -122,8 +117,14 @@ namespace Tango.FSE.Common.FileSystem _transferRateTimer.Start(); } - Position = position; - Length = length; + Progress = new TangoProgress() + { + IsIndeterminate = false, + Value = position, + Maximum = length, + }; + + ProgressChanged?.Invoke(this, new TangoProgressChangedEventArgs(Progress)); if (!IsPaused) { -- cgit v1.3.1