public void Initialize()
        {
            if (DownloadUri != null && DownloadUri.AbsolutePath != "")
            {
                DownloadInfo down = MBDownloadManager.DownloadInfo(DownloadUri.AbsoluteUri);

                if (down != null && down.Id != 0 && down.Uri != "")
                {
                    MBDownloadManager.UpdateNotify(DownloadUri, this);

                    this.DownloadStato = DownloadStato.Downloading;
                }
            }
            else
            {
                this.DownloadStato = DownloadStato.NoUpdate;
            }

            SetUIState();
        }
Exemple #2
0
        public void ConfigureForDownload()
        {
            //pulsante download
            EventHandler onDownClick = (object sender, EventArgs e) =>
            {
                this.Stato = DownloadStato.Downloading;

                //_downloadReference = MBDownloadManager2.Download(_download.Uri, System.IO.Path.GetFileName(_download.Uri.LocalPath), _download.Titolo, this);
                //_downloadReference = MBDownloadManager2.RequestDownload(DownloadUri, System.IO.Path.GetFileName(DownloadUri.LocalPath), this.Title, this);

                MBDownloadManager.RequestDownload(DownloadUri, this);
                SetUIState();

                Log.Info(this.Title, "Inizio download");
            };

            _btnDownload.Click -= onDownClick;
            _btnDownload.Click += onDownClick;

            //pulsante ferma
            EventHandler onStopClick = (object sender, EventArgs e) =>
            {
                //if(_downloadReference != 0)
                {
                    MBDownloadManager.StopDownload(DownloadUri);
                    //_downloadReference = 0;

                    this.Stato = InitStato;
                    SetUIState();
                }
            };

            _btnStop.Click -= onStopClick;
            _btnStop.Click += onStopClick;

            DownloadInfo down = MBDownloadManager.DownloadInfo(DownloadUri.AbsoluteUri);

            if (down != null && down.Id != 0 && down.Uri != "")
            {
                //_downloadReference = down.Id;
                MBDownloadManager.UpdateNotify(DownloadUri, this);

                if (down.Status == DownloadStatus.Running || down.Status == DownloadStatus.Pending)
                {
                    _prgDownload.Progress = 0;
                }
                else if (down.Status == DownloadStatus.Successful)
                {
                    string filePath = new Uri(down.LocalUri).AbsolutePath;
                    if (File.Exists(filePath))
                    {
                        _prgDownload.Progress = 100;
                    }
                }

                this.Stato = DownloadStato.Downloading;
            }
            else if (MBDownloadManager.IsWaiting(DownloadUri))
            {
                _prgDownload.Progress = 0;
                this.Stato            = DownloadStato.Downloading;

                MBDownloadManager.UpdateNotify(DownloadUri, this);
            }

            _btnBuy.SetText(this.Prezzo, TextView.BufferType.Normal);

            SetUIState();
        }