Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- VB.NET
- Public Class myDownload
- Inherits nsIDownload
- <Serializable()> _
- Public Delegate Sub SimpleEventHandler(ByVal sender As Object)
- Private _download As nsIDownload
- #Region "Events"
- Protected Events As EventHandlerList = New EventHandlerList
- Private Shared StartEvent As Object = New Object
- Private Shared CompleteEvent As Object = New Object
- Private Shared FailEvent As Object = New Object
- Private Shared ProgressEvent As Object = New Object
- #Region "public event DownloadStarted"
- <Category("DownloadStarted"), _
- Description("Occurs before the Download was started.")> _
- Public Event DownloadStarted As SimpleEventHandler
- ''' <summary>Raises the <see cref="DownloadStarted"/> event.</summary>
- ''' <param name="e">The data for the event.</param>
- Protected Overridable Sub OnDownloadStarted()
- Dim evnt = CType(Me.Events(StartEvent),SimpleEventHandler)
- If (Not (evnt) Is Nothing) Then
- evnt(Me)
- End If
- End Sub
- #End Region
- #Region "public event DownloadProgress"
- <Category("DownloadProgress"), _
- Description("Occurs before the Download is progressing.")> _
- Public Event DownloadProgress As EventHandler(Of GeckoDownloadProgressEventArgs)
- ''' <summary>Raises the <see cref="DownloadStarted"/> event.</summary>
- ''' <param name="e">The data for the event.</param>
- Protected Overridable Sub OnDownloadProgress(ByVal e As GeckoDownloadProgressEventArgs)
- Dim evnt = CType(Me.Events(ProgressEvent),EventHandler(Of GeckoDownloadProgressEventArgs))
- If (Not (evnt) Is Nothing) Then
- evnt(Me, e)
- End If
- End Sub
- #End Region
- #Region "public event DownloadComplete"
- <Category("DownloadComplete"), _
- Description("Occurs before the Download was completed.")> _
- Public Event DownloadComplete As SimpleEventHandler
- ''' <summary>Raises the <see cref="DownloadStarted"/> event.</summary>
- ''' <param name="e">The data for the event.</param>
- Protected Overridable Sub OnDownloadComplete()
- Dim evnt = CType(Me.Events(CompleteEvent),SimpleEventHandler)
- If (Not (evnt) Is Nothing) Then
- evnt(Me)
- End If
- End Sub
- #End Region
- #Region "public event DownloadFailed"
- <Category("DownloadFailed"), _
- Description("Occurs before the Download was started.")> _
- Public Event DownloadFailed As SimpleEventHandler
- ''' <summary>Raises the <see cref="DownloadStarted"/> event.</summary>
- ''' <param name="e">The data for the event.</param>
- Protected Overridable Sub OnDownloadFailed()
- Dim evnt = CType(Me.Events(FailEvent),SimpleEventHandler)
- If (Not (evnt) Is Nothing) Then
- evnt(Me)
- End If
- End Sub
- #End Region
- #End Region
- Public ID As Long
- Public Source As Uri
- Public File As String
- Public Size As Long
- Public Mime As String
- Public Sub New(ByVal download As nsIDownload)
- MyBase.New
- Me._download = download
- Me.ID = DateTime.Now.Ticks
- Me.Source = New nsURI(Me._download.GetSourceAttribute).ToUri
- Me.File = nsString.Get(Me._download.GetTargetFileAttribute.GetTargetAttribute)
- Me.Size = Me._download.GetSizeAttribute
- Dim a = Me._download.GetMIMEInfoAttribute
- If (Not (a) Is Nothing) Then
- Me.Mime = nsString.Get(a.GetMIMETypeAttribute)
- End If
- End Sub
- #Region "STATIC Downloads Methods"
- Private Shared DownloadManager As nsIDownloadManager = Nothing
- Public Shared Sub CleanUpDownloads()
- If (DownloadManager Is Nothing) Then
- DownloadManager = Xpcom.CreateInstance(Of nsIDownloadManager)("@mozilla.org/download-manager;1")
- End If
- Dim enu As nsISimpleEnumerator = DownloadManager.GetActiveDownloadsAttribute
- While enu.HasMoreElements
- Dim d As nsIDownload = CType(enu.GetNext,nsIDownload)
- Dim c As nsICancelable = d.GetCancelableAttribute
- DownloadManager.CancelDownload(d.GetIdAttribute)
- End While
- DownloadManager.CleanUp
- End Sub
- Public Shared Function downloadFile(ByVal localfile As String, ByVal url As String) As myDownload
- If (DownloadManager Is Nothing) Then
- DownloadManager = Xpcom.CreateInstance(Of nsIDownloadManager)("@mozilla.org/download-manager;1")
- End If
- Dim source As nsIURI = IOService.CreateNsIUri(url)
- Dim dest As nsIURI = IOService.CreateFileNsIUri(localfile)
- Dim objTarget = Xpcom.CreateInstance(Of nsILocalFile)("@mozilla.org/file/local;1")
- Dim tmp As nsAString = New nsAString(localfile)
- objTarget.InitWithPath(tmp)
- Dim persist As nsIWebBrowserPersist = Xpcom.CreateInstance(Of nsIWebBrowserPersist)("@mozilla.org/embedding/browser/nsWebBrowserPersist;1")
- Dim download As nsIDownload = Nothing
- Dim t As nsAStringBase = CType(New nsAString(Path.GetFileName(localfile)),nsAStringBase)
- download = DownloadManager.AddDownload(0, source, dest, t, Nothing, 0, Nothing, CType(persist,nsICancelable))
- If (Not (download) Is Nothing) Then
- Dim myD As myDownload = New myDownload(download)
- persist.SetPersistFlagsAttribute((2 Or (32 Or 16384)))
- persist.SetProgressListenerAttribute(CType(myD,nsIWebProgressListener))
- persist.SaveURI(source, Nothing, Nothing, Nothing, Nothing, CType(dest,nsISupports))
- Return myD
- End If
- Return Nothing
- End Function
- #End Region
- Public Sub CancelDownload()
- If (DownloadManager Is Nothing) Then
- DownloadManager = Xpcom.CreateInstance(Of nsIDownloadManager)("@mozilla.org/download-manager;1")
- End If
- DownloadManager.CancelDownload(Me.GetIdAttribute)
- DownloadManager.RemoveDownload(Me.GetIdAttribute)
- End Sub
- Public Sub PauseDownload()
- DownloadManager.PauseDownload(Me.GetIdAttribute)
- End Sub
- Public Sub ResumeDownload()
- DownloadManager.ResumeDownload(Me.GetIdAttribute)
- End Sub
- Public Function GetAmountTransferredAttribute() As Long
- Return Me._download.GetAmountTransferredAttribute
- End Function
- Public Function GetCancelableAttribute() As Gecko.nsICancelable
- Return Me._download.GetCancelableAttribute
- End Function
- Public Sub GetDisplayNameAttribute(ByVal aDisplayName As Gecko.nsAStringBase)
- Me._download.GetDisplayNameAttribute(aDisplayName)
- End Sub
- Public Function GetIdAttribute() As UInteger
- Return Me._download.GetIdAttribute
- End Function
- Public Function GetMIMEInfoAttribute() As Gecko.nsIMIMEInfo
- Return Me._download.GetMIMEInfoAttribute
- End Function
- Public Function GetPercentCompleteAttribute() As Integer
- Return Me._download.GetPercentCompleteAttribute
- End Function
- Public Function GetReferrerAttribute() As Gecko.nsIURI
- Return Me._download.GetReferrerAttribute
- End Function
- Public Function GetResumableAttribute() As Boolean
- Return Me._download.GetResumableAttribute
- End Function
- Public Function GetSizeAttribute() As Long
- Return Me._download.GetSizeAttribute
- End Function
- Public Function GetSourceAttribute() As nsIURI
- Return Me._download.GetSourceAttribute
- End Function
- Public Function GetSpeedAttribute() As Double
- Return Me._download.GetSpeedAttribute
- End Function
- Public Function GetStartTimeAttribute() As Long
- Return Me._download.GetStartTimeAttribute
- End Function
- Public Function GetStateAttribute() As Short
- Return Me._download.GetStateAttribute
- End Function
- Public Function GetTargetAttribute() As nsIURI
- Return Me._download.GetTargetAttribute
- End Function
- Public Function GetTargetFileAttribute() As nsIFile
- Return Me._download.GetTargetFileAttribute
- End Function
- Public Sub Init(ByVal aSource As Gecko.nsIURI, ByVal aTarget As Gecko.nsIURI, ByVal aDisplayName As Gecko.nsAStringBase, ByVal aMIMEInfo As Gecko.nsIMIMEInfo, ByVal startTime As Long, ByVal aTempFile As Gecko.nsIFile, ByVal aCancelable As Gecko.nsICancelable)
- Me._download.Init(aSource, aTarget, aDisplayName, aMIMEInfo, startTime, aTempFile, aCancelable)
- End Sub
- Public Sub OnLocationChange(ByVal aWebProgress As Gecko.nsIWebProgress, ByVal aRequest As Gecko.nsIRequest, ByVal aLocation As Gecko.nsIURI, ByVal aFlags As UInteger)
- Me._download.OnLocationChange(aWebProgress, aRequest, aLocation, aFlags)
- End Sub
- Public Sub OnProgressChange(ByVal aWebProgress As Gecko.nsIWebProgress, ByVal aRequest As Gecko.nsIRequest, ByVal aCurSelfProgress As Integer, ByVal aMaxSelfProgress As Integer, ByVal aCurTotalProgress As Integer, ByVal aMaxTotalProgress As Integer)
- Me.OnDownloadProgress(New GeckoDownloadProgressEventArgs(aCurTotalProgress, aMaxTotalProgress, Me._download.GetPercentCompleteAttribute, Me._download.GetSpeedAttribute))
- Me._download.OnProgressChange(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress)
- End Sub
- Public Sub OnProgressChange64(ByVal aWebProgress As Gecko.nsIWebProgress, ByVal aRequest As Gecko.nsIRequest, ByVal aCurSelfProgress As Long, ByVal aMaxSelfProgress As Long, ByVal aCurTotalProgress As Long, ByVal aMaxTotalProgress As Long)
- Me.OnDownloadProgress(New GeckoDownloadProgressEventArgs(aCurTotalProgress, aMaxTotalProgress, Me._download.GetPercentCompleteAttribute, Me._download.GetSpeedAttribute))
- Me._download.OnProgressChange64(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress)
- End Sub
- Public Function OnRefreshAttempted(ByVal aWebProgress As Gecko.nsIWebProgress, ByVal aRefreshURI As Gecko.nsIURI, ByVal aMillis As Integer, ByVal aSameURI As Boolean) As Boolean
- Return Me._download.OnRefreshAttempted(aWebProgress, aRefreshURI, aMillis, aSameURI)
- End Function
- Public Sub OnSecurityChange(ByVal aWebProgress As Gecko.nsIWebProgress, ByVal aRequest As Gecko.nsIRequest, ByVal aState As UInteger)
- Me._download.OnSecurityChange(aWebProgress, aRequest, aState)
- End Sub
- Public Sub OnStateChange(ByVal aWebProgress As Gecko.nsIWebProgress, ByVal aRequest As Gecko.nsIRequest, ByVal aStateFlags As UInteger, ByVal aStatus As Integer)
- If ((aStateFlags And nsIWebProgressListenerConstants.STATE_START) _
- <> 0) Then
- ' Start
- Me.OnDownloadStarted
- End If
- If ((aStateFlags And nsIWebProgressListenerConstants.STATE_STOP) _
- <> 0) Then
- ' Stop
- If (aStatus <> 0) Then
- ' ERROR FailEvent
- Me.OnDownloadFailed
- Else
- ' COMPLETE CompleteEvent
- Me.OnDownloadComplete
- End If
- End If
- Me._download.OnStateChange(aWebProgress, aRequest, aStateFlags, aStatus)
- End Sub
- Public Sub OnStatusChange(ByVal aWebProgress As Gecko.nsIWebProgress, ByVal aRequest As Gecko.nsIRequest, ByVal aStatus As Integer, ByVal aMessage As String)
- Me._download.OnStatusChange(aWebProgress, aRequest, aStatus, aMessage)
- End Sub
- End Class
- UnknownPublic Class GeckoDownloadProgressEventArgs
- Inherits EventArgs
- Public CurrentProgress As Long
- Public MaxProgress As Long
- Public ProgressPercent As Integer
- Public Speed As Double
- Public LeftTime As TimeSpan
- ''' <summary>Creates a new instance of a <see cref="GeckoDownloadEventArgs"/> object.</summary>
- ''' <param name="value"></param>
- ''' <param name="response"></param>
- Friend Sub New(ByVal currentProgress As Long, ByVal maxProgress As Long, ByVal progressPercent As Integer, ByVal speed As Double)
- MyBase.New
- Me.CurrentProgress = currentProgress
- Me.MaxProgress = maxProgress
- Me.ProgressPercent = progressPercent
- Me.Speed = speed
- If (speed > 100) Then
- Me.LeftTime = New TimeSpan(0, 0, CType(((maxProgress - currentProgress) _
- / speed),Integer))
- Else
- Me.LeftTime = New TimeSpan(0)
- End If
- End Sub
- End Class
- c#
- public class myDownload : nsIDownload
- {
- [Serializable]
- public delegate void SimpleEventHandler(object sender);
- private nsIDownload _download;
- #region Events
- protected EventHandlerList Events = new EventHandlerList();
- private static readonly object StartEvent = new object();
- private static readonly object CompleteEvent = new object();
- private static readonly object FailEvent = new object();
- private static readonly object ProgressEvent = new object();
- #region public event DownloadStarted
- /// <summary>
- /// Occurs before the Download was started.
- /// </summary>
- [Category("DownloadStarted")]
- [Description("Occurs before the Download was started.")]
- public event SimpleEventHandler DownloadStarted
- {
- add { Events.AddHandler(StartEvent, value); }
- remove { Events.RemoveHandler(StartEvent, value); }
- }
- /// <summary>Raises the <see cref="DownloadStarted"/> event.</summary>
- /// <param name="e">The data for the event.</param>
- protected virtual void OnDownloadStarted()
- {
- var evnt = ((SimpleEventHandler)Events[StartEvent]);
- if (evnt != null) evnt(this);
- }
- #endregion
- #region public event DownloadProgress
- /// <summary>
- /// Occurs before the Download was started.
- /// </summary>
- [Category("DownloadProgress")]
- [Description("Occurs before the Download is progressing.")]
- public event EventHandler<GeckoDownloadProgressEventArgs> DownloadProgress
- {
- add { Events.AddHandler(ProgressEvent, value); }
- remove { Events.RemoveHandler(ProgressEvent, value); }
- }
- /// <summary>Raises the <see cref="DownloadStarted"/> event.</summary>
- /// <param name="e">The data for the event.</param>
- protected virtual void OnDownloadProgress(GeckoDownloadProgressEventArgs e)
- {
- var evnt = ((EventHandler<GeckoDownloadProgressEventArgs>)Events[ProgressEvent]);
- if (evnt != null) evnt(this, e);
- }
- #endregion
- #region public event DownloadComplete
- /// <summary>
- /// Occurs before the Download was started.
- /// </summary>
- [Category("DownloadComplete")]
- [Description("Occurs before the Download was completed.")]
- public event SimpleEventHandler DownloadComplete
- {
- add { Events.AddHandler(CompleteEvent, value); }
- remove { Events.RemoveHandler(CompleteEvent, value); }
- }
- /// <summary>Raises the <see cref="DownloadStarted"/> event.</summary>
- /// <param name="e">The data for the event.</param>
- protected virtual void OnDownloadComplete()
- {
- var evnt = ((SimpleEventHandler)Events[CompleteEvent]);
- if (evnt != null) evnt(this);
- }
- #endregion
- #region public event DownloadFailed
- /// <summary>
- /// Occurs before the Download was started.
- /// </summary>
- [Category("DownloadFailed")]
- [Description("Occurs before the Download was started.")]
- public event SimpleEventHandler DownloadFailed
- {
- add { Events.AddHandler(FailEvent, value); }
- remove { Events.RemoveHandler(FailEvent, value); }
- }
- /// <summary>Raises the <see cref="DownloadStarted"/> event.</summary>
- /// <param name="e">The data for the event.</param>
- protected virtual void OnDownloadFailed()
- {
- var evnt = ((SimpleEventHandler)Events[FailEvent]);
- if (evnt != null) evnt(this);
- }
- #endregion
- #endregion
- public long ID;
- public readonly Uri Source;
- public readonly string File;
- public readonly long Size;
- public readonly string Mime;
- public myDownload(nsIDownload download)
- {
- _download = download;
- ID = DateTime.Now.Ticks;
- Source = (new nsURI(_download.GetSourceAttribute())).ToUri();
- File = nsString.Get(_download.GetTargetFileAttribute().GetTargetAttribute);
- Size = _download.GetSizeAttribute();
- var a = _download.GetMIMEInfoAttribute();
- if (a != null)
- Mime = nsString.Get(a.GetMIMETypeAttribute);
- }
- # region STATIC Downloads Methods
- static nsIDownloadManager DownloadManager = null;
- static public void CleanUpDownloads()
- {
- if (DownloadManager == null)
- DownloadManager = Xpcom.CreateInstance<nsIDownloadManager>("@mozilla.org/download-manager;1");
- nsISimpleEnumerator enu = DownloadManager.GetActiveDownloadsAttribute();
- while (enu.HasMoreElements())
- {
- nsIDownload d = (nsIDownload)enu.GetNext();
- nsICancelable c = d.GetCancelableAttribute();
- DownloadManager.CancelDownload(d.GetIdAttribute());
- };
- DownloadManager.CleanUp();
- }
- static public myDownload downloadFile(string localfile, string url)
- {
- if (DownloadManager == null)
- DownloadManager = Xpcom.CreateInstance<nsIDownloadManager>("@mozilla.org/download-manager;1");
- nsIURI source = IOService.CreateNsIUri(url);
- nsIURI dest = IOService.CreateFileNsIUri(localfile);
- var objTarget = Xpcom.CreateInstance<nsILocalFile>("@mozilla.org/file/local;1");
- using (nsAString tmp = new nsAString(localfile))
- objTarget.InitWithPath(tmp);
- nsIWebBrowserPersist persist = Xpcom.CreateInstance<nsIWebBrowserPersist>("@mozilla.org/embedding/browser/nsWebBrowserPersist;1");
- nsIDownload download = null;
- nsAStringBase t = (nsAStringBase)new nsAString(Path.GetFileName(localfile));
- download = DownloadManager.AddDownload(0, source, dest, t, null, 0, null, (nsICancelable)persist);
- if (download != null)
- {
- myDownload myD = new myDownload(download);
- persist.SetPersistFlagsAttribute(2 | 32 | 16384);
- persist.SetProgressListenerAttribute((nsIWebProgressListener)myD);
- persist.SaveURI(source, null, null, null, null, (nsISupports)dest);
- return myD;
- }
- return null;
- }
- #endregion
- public void CancelDownload()
- {
- if (DownloadManager == null)
- DownloadManager = Xpcom.CreateInstance<nsIDownloadManager>("@mozilla.org/download-manager;1");
- DownloadManager.CancelDownload(GetIdAttribute());
- DownloadManager.RemoveDownload(GetIdAttribute());
- }
- public void PauseDownload()
- {
- DownloadManager.PauseDownload(GetIdAttribute());
- }
- public void ResumeDownload()
- {
- DownloadManager.ResumeDownload(GetIdAttribute());
- }
- public long GetAmountTransferredAttribute()
- {
- return _download.GetAmountTransferredAttribute();
- }
- public Gecko.nsICancelable GetCancelableAttribute()
- {
- return _download.GetCancelableAttribute();
- }
- public void GetDisplayNameAttribute(Gecko.nsAStringBase aDisplayName)
- {
- _download.GetDisplayNameAttribute(aDisplayName);
- }
- public uint GetIdAttribute()
- {
- return _download.GetIdAttribute();
- }
- public Gecko.nsIMIMEInfo GetMIMEInfoAttribute()
- {
- return _download.GetMIMEInfoAttribute();
- }
- public int GetPercentCompleteAttribute()
- {
- return _download.GetPercentCompleteAttribute();
- }
- public Gecko.nsIURI GetReferrerAttribute()
- {
- return _download.GetReferrerAttribute();
- }
- public bool GetResumableAttribute()
- {
- return _download.GetResumableAttribute();
- }
- public long GetSizeAttribute()
- {
- return _download.GetSizeAttribute();
- }
- public nsIURI GetSourceAttribute()
- {
- return _download.GetSourceAttribute();
- }
- public double GetSpeedAttribute()
- {
- return _download.GetSpeedAttribute();
- }
- public long GetStartTimeAttribute()
- {
- return _download.GetStartTimeAttribute();
- }
- public short GetStateAttribute()
- {
- return _download.GetStateAttribute();
- }
- public nsIURI GetTargetAttribute()
- {
- return _download.GetTargetAttribute();
- }
- public nsIFile GetTargetFileAttribute()
- {
- return _download.GetTargetFileAttribute();
- }
- public void Init(Gecko.nsIURI aSource, Gecko.nsIURI aTarget, Gecko.nsAStringBase aDisplayName, Gecko.nsIMIMEInfo aMIMEInfo, long startTime, Gecko.nsIFile aTempFile, Gecko.nsICancelable aCancelable)
- {
- _download.Init(aSource, aTarget, aDisplayName, aMIMEInfo, startTime, aTempFile, aCancelable);
- }
- public void OnLocationChange(Gecko.nsIWebProgress aWebProgress, Gecko.nsIRequest aRequest, Gecko.nsIURI aLocation, uint aFlags)
- {
- _download.OnLocationChange(aWebProgress, aRequest, aLocation, aFlags);
- }
- public void OnProgressChange(Gecko.nsIWebProgress aWebProgress, Gecko.nsIRequest aRequest, int aCurSelfProgress, int aMaxSelfProgress, int aCurTotalProgress, int aMaxTotalProgress)
- {
- OnDownloadProgress(new GeckoDownloadProgressEventArgs(aCurTotalProgress, aMaxTotalProgress, _download.GetPercentCompleteAttribute(), _download.GetSpeedAttribute()));
- _download.OnProgressChange(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress);
- }
- public void OnProgressChange64(Gecko.nsIWebProgress aWebProgress, Gecko.nsIRequest aRequest, long aCurSelfProgress, long aMaxSelfProgress, long aCurTotalProgress, long aMaxTotalProgress)
- {
- OnDownloadProgress(new GeckoDownloadProgressEventArgs(aCurTotalProgress, aMaxTotalProgress, _download.GetPercentCompleteAttribute(), _download.GetSpeedAttribute()));
- _download.OnProgressChange64(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress);
- }
- public bool OnRefreshAttempted(Gecko.nsIWebProgress aWebProgress, Gecko.nsIURI aRefreshURI, int aMillis, bool aSameURI)
- {
- return _download.OnRefreshAttempted(aWebProgress, aRefreshURI, aMillis, aSameURI);
- }
- public void OnSecurityChange(Gecko.nsIWebProgress aWebProgress, Gecko.nsIRequest aRequest, uint aState)
- {
- _download.OnSecurityChange(aWebProgress, aRequest, aState);
- }
- public void OnStateChange(Gecko.nsIWebProgress aWebProgress, Gecko.nsIRequest aRequest, uint aStateFlags, int aStatus)
- {
- if ((aStateFlags & nsIWebProgressListenerConstants.STATE_START) != 0)
- {
- // Start
- OnDownloadStarted();
- }
- if ((aStateFlags & nsIWebProgressListenerConstants.STATE_STOP) != 0)
- {
- // Stop
- if (aStatus != 0)
- {
- // ERROR FailEvent
- OnDownloadFailed();
- }
- else
- {
- // COMPLETE CompleteEvent
- OnDownloadComplete();
- }
- }
- _download.OnStateChange(aWebProgress, aRequest, aStateFlags, aStatus);
- }
- public void OnStatusChange(Gecko.nsIWebProgress aWebProgress, Gecko.nsIRequest aRequest, int aStatus, string aMessage)
- {
- _download.OnStatusChange(aWebProgress, aRequest, aStatus, aMessage);
- }
- }
- }
- public class GeckoDownloadProgressEventArgs
- : EventArgs
- {
- public readonly long CurrentProgress;
- public readonly long MaxProgress;
- public readonly int ProgressPercent;
- public readonly double Speed;
- public readonly TimeSpan LeftTime;
- /// <summary>Creates a new instance of a <see cref="GeckoDownloadEventArgs"/> object.</summary>
- /// <param name="value"></param>
- /// <param name="response"></param>
- internal GeckoDownloadProgressEventArgs(long currentProgress, long maxProgress, int progressPercent, double speed)
- {
- CurrentProgress = currentProgress;
- MaxProgress = maxProgress;
- ProgressPercent = progressPercent;
- Speed = speed;
- if (speed > 100.0)
- LeftTime = new TimeSpan(0, 0, (int)((maxProgress - currentProgress) / speed));
- else
- LeftTime = new TimeSpan(0);
- }
- }
Add Comment
Please, Sign In to add comment