示例#1
0
        public async Task <FileDownload> ProcessUrl(string url)
        {
            if (!PauseAllEnabled)
            {
                return(null);
            }
            var item = new TaskDataGridItem
            {
                Url            = url,
                DownloadStatus = Enum.GetName(typeof(DownloadStatus), DownloadStatus.Downloading),
                Progress       = 0
            };

            var          tokenSource  = new CancellationTokenSource();
            FileDownload fileDownload = new FileDownload(url, ChunkSize, tokenSource);

            fileDownload.DownloadProgressChanged += FileDownload_DownloadProgressChanged;
            fileDownload.DownloadCompleted       += FileDownload_DownloadCompleted;
            fileDownload.DownloadError           += FileDownload_DownloadError;

            Application.Current.Dispatcher.Invoke(() =>
                                                  GridItems.Add(item));
            this._downloads.Add(fileDownload);
            Interlocked.Increment(ref _currentRunningThreads);

            OnPropertyChanged(nameof(CurrentThreadsToShow));
            await fileDownload.Start();

            return(fileDownload);
        }
示例#2
0
 public void CreateGridItems()
 {
     while (xamlitems.Count >= 2)
     {
         var res = new GridItem(xamlitems);
         GridItems.Add(res);
     }
 }
示例#3
0
        public void AddGridItem()
        {
            GridItem item = new GridItem();

            item.ID = GridItems.Count;
            item.OnGridItemInvalidate += new GridItem.GridItemInvalidateHandle(this.OnGridItemInvalidateHandle);
            item.OnContentReset       += new GridItem.ResetControlHandle(this.OnResetControlHandle);
            GridItems.Add(item);
        }
示例#4
0
        private ObservableCollection <SzablonItem> PopulateSzablon()
        {
            IFormatter formatter = new BinaryFormatter();

            //
            try
            {
                return(GridItems = Powykonawcza.Services.WPFtemplateService.TryLoadTemplateFromFile());
            }
            catch
            {
                //return GridItems = Powykonawcza.Services.WPFtemplateService.PopulateDefaultTemplate();
                var item = Powykonawcza.Services.WPFtemplateService.PopulateDefaultTemplate();
                foreach (var i in item)
                {
                    GridItems.Add(i);
                }
                return(GridItems);
            }
        }