CommunityToolkit / WindowsCommunityToolkit

The Windows Community Toolkit is a collection of helpers, extensions, and custom controls. It simplifies and demonstrates common developer tasks building .NET apps with UWP and the Windows App SDK / WinUI 3 for Windows 10 and Windows 11. The toolkit is part of the .NET Foundation.
https://docs.microsoft.com/windows/communitytoolkit/
Other
5.87k stars 1.37k forks source link

New Helper for Downloading from the web #1309

Closed Vijay-Nirmal closed 3 years ago

Vijay-Nirmal commented 7 years ago

Downloading from the web is a very common thing to do in Apps but it doesn't have any dedicated control for it. So it would be nice to have one.

Feature request for this control:

hermitdave commented 7 years ago

Hi @Vijay-Nirmal thank you for the suggestion. To gauge wider interest, can you please create a uservoice entry with as much detail as possible ?

https://wpdev.uservoice.com/forums/110705-universal-windows-platform/category/193402-uwp-community-toolkit.

Vijay-Nirmal commented 7 years ago

I have created UserVoice

@hermitdave Give a search in StackOverflow. You can see many people trying to use Downloader.

nmetulev commented 7 years ago

Hey @Vijay-Nirmal, what benefits would this helper provide over the BackgroundDownloader?

Vijay-Nirmal commented 7 years ago

@nmetulev Does BackgroundDownloader have are the features I mentioned in my post? Also, this helper makes it easy to create controls for downloading like the example below

<TextBlock Text="{x:Bind downloader.GetSpeed}"/> //To display speed
<ProgressBar Value="{x:Bind downloader.GetPercentage}"/> //To display Progress Bar for downloading

This helper should have built in INotifyPropertyChanged

nmetulev commented 7 years ago

So basically a wrapper around DownloadOperation?

Vijay-Nirmal commented 7 years ago

@nmetulev I think so. This helper will help to implement all the basic functions (Like Start, Stop, Pause, get speed, setting the speed limit, downloading multiple files, name and size of the downloading item) very easily. I don't think it will be a duplicate of DownloadOperation

Odonno commented 7 years ago

@Vijay-Nirmal Seems interesting if you can also create a page example that can easily be replicated in any app.

Vijay-Nirmal commented 7 years ago

@Odonno I didn't get your point but sounds good to me :) What do you mean by "page example"?

Odonno commented 7 years ago

@Vijay-Nirmal A page with some UI controls demonstrating the download of a file. And, another question, if it works with Download, can it work with Upload?

Vijay-Nirmal commented 7 years ago

@Odonno

if it works with Download, can it work with Upload?

That is a good point. I love to see that. If we do this then we should change the name of the helper :)

Vijay-Nirmal commented 7 years ago

From the design point of view. How can we make it easy to create a ListView like Windows Store?

private ObservableCollection<DownloadsItem> DownloadsItemSource = new ObservableCollection<DownloadsItem>();

public class DownloadsItem
{
    public BitmapImage Logo { get; set; }
    public Downloader downloader { get; set; }
}
<Page.Resources>
    <converters:BoolToObjectConverter x:Key="BoolToIconConverter" TrueValue="&#xE102;" FalseValue="&#xE103;" />
</Page.Resources>

<ListView ItemsSource="{x:Bind DownloadsItemSource}">
    <ListView.ItemTemplate>
        <DataTemplate x:DataType="local:DownloadsItem">
            <StackPanel Orientation="Horizontal">
                <Image Name="DownloadLogo" Source="{x:Bind Logo}"/>
                <TextBlock Name="DownloadName" Text="{x:Bind downloader.GetInfo.Name}"/>
                <StackPanel>
                    <TextBlock Name="Downloaded" Text="{x:Bind downloader.Downloaded}"/>
                    <ProgressBar Name="DownloadProgressBar" Value="{x:Bind GetPercentage}"/>
                    <TextBlock Name="DownloadSpeed" Text="{x:Bind downloader.GetSpeed}"/>
                </StackPanel>
                <Button Name="StartPause" FontFamily="Segoe MDL2 Assets" Content="{x:Bind Path=downloader.IsPaused, Converter={StaticResource BoolToBrushConverter}}"/>
                <Button Name="Cancel" FontFamily="Segoe MDL2 Assets" Content="&#xE10A;"/>
            </StackPanel>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

This method contains few problems.

  1. How can we manage "downloading multiple files"? like limiting the number of downloads at once
  2. There should we a direct way to bind Button click to Cancel, Start, Stop.
hermitdave commented 7 years ago

@Vijay-Nirmal uploading is a very different ball game

Vijay-Nirmal commented 7 years ago

@hermitdave But it will also have the sample controls like start, pause, cancel, ProgressBar

Odonno commented 7 years ago

I am not sure if it's the best solution but we can create a DownloadItem or DownloadItemNotification class which contains a boolean (IsRunning) and an integer value (Percentage, from 0 to 100). These properties should be updated using INotifyPropertyChanged.

Of course, you can add Speed as a third notifiable property.

Vijay-Nirmal commented 7 years ago

@Odonno What would be the best solution to start, pause, stop, cancel?

There should we a direct way to bind Button click to Cancel, Start, Stop

Odonno commented 7 years ago

@Vijay-Nirmal Not sure what you mean by "direct", but you can simply use a Command or use x:Bind to stop the Download.

Vijay-Nirmal commented 6 years ago

Is it possible to add Parallel Downloading support like IDM to increase the overall download speed?

lucaasrojas commented 6 years ago

Whats the current status of this issue?

Kyaa-dost commented 4 years ago

@Vijay-Nirmal Any update on this?

Kyaa-dost commented 4 years ago

@Vijay-Nirmal is this being worked on your end or are we still planning to move with this any further?

Vijay-Nirmal commented 4 years ago

I didn't work on this. If we need to proceed with this feature then I maybe (If I have time) able to work on this.

Kyaa-dost commented 4 years ago

@michael-hawker is this something we want to proceed with?

LanceMcCarthy commented 3 years ago

I did something this years ago, you can use it as a head start.

image

See https://github.com/LanceMcCarthy/UwpProjects Scroll down to DownloadStreamwithProgressAsync https://github.com/LanceMcCarthy/UwpProjects#downloadstreamwithprogressasync-httpclient-extension

mrlacey commented 3 years ago

The original discussion seems to have been distracted by talk of uploading and recreating the store app UI for handling multiple concurrent downloads.

I suspect downloading individual files is something that is common enough that adding a helper to make this simpler would benefit a large number of developers. They could then add UI or multiple file functionality as necessary.

I'm not clear if this should be a purely code-based helper or come with UI.

For reference: https://docs.microsoft.com/en-us/samples/microsoft/windows-universal-samples/backgroundtransfer/

michael-hawker commented 3 years ago

Thanks @mrlacey. I agree, a simple helper like @LanceMcCarthy provided to aid in downloads would be great. Hooking up UI or anything else can be left to the developer. Though I'm thinking combined with the new MVVM Toolkit too, we could probably have a pretty simple example to demonstrate this too. @Sergio0694 does the Task binding/helpers support progress somehow at all?

For more complex UI or helpers beyond that I think are beyond the scope of the original issue. They're probably best left as a separate issue for further discussion (though I'm not sure if the Toolkit would be the best place for that depending on the proposal).

Kyaa-dost commented 3 years ago

Moving this to our discussions channel.