DownloadItem ClassAwesomium.NET 1.7.6Awesomium.NET
Represents a download operation maintained by the WebCore.
Inheritance Hierarchy

SystemObject
  Awesomium.CoreViewModel
    Awesomium.CoreDownloadItem
      Awesomium.Windows.ControlsDownloadItem

Namespace: Awesomium.Core
Assembly: Awesomium.Core (in Awesomium.Core.dll) Version: 1.7.6.0
Syntax

public class DownloadItem : ViewModel

The DownloadItem type exposes the following members.

Methods

  NameDescription
Public methodCanCancel
Determines if the download operation can be canceled.
Public methodCancel
Cancels this download operation.
Public methodCanOpenDownloadedFile
Determines if the downloaded file can be opened.
Public methodCanOpenDownloadedFileFolder
Determines if the folder containing the downloaded file can be opened.
Public methodCanRemove
Determines if the download operation can be removed from Downloads.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Overrides ObjectEquals(Object).)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Overrides ObjectGetHashCode.)
Protected methodOnCanceled
Triggers the Canceled event.
Protected methodOnCanceling
Triggers the Canceling event.
Protected methodOnCompleted
Triggers the Completed event.
Protected methodOnProgressChanged
Triggers the ProgressChanged event.
Protected methodOnPropertyChanged
Triggers the PropertyChanged event.
(Inherited from ViewModel.)
Public methodOpenDownloadedFile
Attempts to open the downloaded file, launching the application that is associated with the file's type.
Public methodOpenDownloadedFileFolder
Attempts to open the folder containing the downloaded file.
Protected methodRaisePropertyChanged
Helper method to raise the PropertyChanged event.
(Inherited from ViewModel.)
Public methodRemove
Removes a complete or canceled operation from Downloads.
Top
Operators

  NameDescription
Public operatorStatic memberEquality
Tests whether two specified DownloadItem instances are equivalent.
Public operatorStatic memberInequality
Tests whether two specified DownloadItem instances are not equal.
Top
Properties

  NameDescription
Public propertyCurrentSpeed
Gets the current downloading speed, or 0 if the operation is canceled or complete.
Public propertyFileName
Gets the name of the downloaded file.
Public propertyIsActive
Gets if the download operation represented by this class, is currently active.
Public propertyIsCanceled
Gets if the download operation represented by this class, has been canceled.
Public propertyIsComplete
Gets if the download operation represented by this class, has completed.
Public propertyMimeType
Gets the mime type of the file downloaded.
Public propertyOriginViewId
Gets the unique identifier of the view that initiated the download operation. This corresponds to Identifier.
Public propertyProgress
Gets the operation's progress percentage.
Public propertyReceivedBytes
Gets the number of bytes received so far.
Public propertySavePath
Gets the full path to the downloaded file.
Public propertyTotalBytes
Gets the total number of bytes (may be 0 if unknown).
Public propertyUrl
Gets the URL that initiated the download.
Public propertyWebSession
Gets the WebSession instance that controls this download operation.
Top
Events

  NameDescription
Public eventCanceled
Occurs when this download operation is canceled.
Public eventCanceling
Occurs when this download operation is about to be canceled, as a result of calling Cancel.
Public eventCompleted
Occurs when this download operation is complete.
Public eventProgressChanged
Occurs when the status of this download operation has changed.
Public eventPropertyChanged
Occurs when the value of a property of this class, has changed.
(Inherited from ViewModel.)
Top
Remarks

DownloadItem is a ViewModel instance (therefore it implements INotifyPropertyChanged). This makes it ideal for use directly as a view model in an MVVM application.

An instance of DownloadItem is first created when the DownloadBegin event is fired, to indicate that the download operation is about to start. The DownloadItem instance is added to the Downloads collection immediately after DownloadBegin.

Developers can access the DownloadItem instance either through the DownloadBegin event (see Info), or through the Downloads collection (DownloadCollection implements INotifyCollectionChanged). For more details, read the following article: Handling Downloads.

Repeating a Download Operation

Two DownloadItem instances are considered equal when the originating Url, MimeType and destination path (see SavePath), are equal. This means that if you attempt to download the same file, from the same URL and save it to the same destination, Awesomium.NET will restart the old download operation instead of creating a new one. In this scenario there will be no change to the Downloads collection after the DownloadBegin event if fired. What's more, Info will return the existing DownloadItem representing the previous download operation, with the values of all its members intact: For example, IsComplete may be true and ReceivedBytes will reflect the number of bytes received during the previous operation. These values will only be reset after the DownloadBegin event.

This behavior is useful for the following reasons:

  • If you are using the Downloads collection as a data source in an MVVM application, you wouldn't want a new DownloadItem item be created for a download operation that is actually being repeated.
  • The new (repeated) download operation, can still be canceled at DownloadBegin by setting Cancel to true. Letting the members of the reused DownloadItem instance intact during DownloadBegin, allows users to cancel the operation without affecting the appearance and behavior of the visual element bound to the reused DownloadItem instance.

    When the download operation starts (immediately after DownloadBegin), the members of the reused DownloadItem instance will be reset allowing any bound visual element reflect that a previous download operation, is being repeated.

See Also

Reference