void HandleQueueDownloaderOnStart(LocalProgram startedProgram, int queueSize) { InvokeOnMainThread(delegate { Console.WriteLine("{0} has started", startedProgram.Name); TitleLabel.Text = startedProgram.Name; TitleLabel.SetNeedsDisplay(); ImageView.Image = RemoteProgramHelper.GetFullsizeImageFromFile(startedProgram.ThumbnailPath, ImageView.Bounds); if (queueSize == 0) { SubLabel.Text = "Downloading. No more items in the queue"; } else if (queueSize == 1) { SubLabel.Text = String.Format("Downloading. {0} item remaining to download", queueSize); } else { SubLabel.Text = string.Format("Downloading. {0} items remaining to download", queueSize); } SubLabel.SetNeedsDisplay(); ProgressBar.Progress = 0; ProgressBar.SetNeedsDisplay(); }); }
public override void ViewDidLoad() { base.ViewDidLoad(); CloseButton.TouchUpInside += delegate { DismissModalViewControllerAnimated(true); }; CloseButton.Hidden = true; queueDownloader = new QueueDownloader(); queueDownloader.Queue = AppDelegate.SessionDatabase.GetLocalQueuedPrograms(); if (queueDownloader.Queue.Count > 0) { LocalProgram firstProgram = queueDownloader.Queue[0]; TitleLabel.Text = firstProgram.Name; ImageView.Image = RemoteProgramHelper.GetFullsizeImageFromFile(firstProgram.ThumbnailPath, ImageView.Bounds); int queueSize = queueDownloader.Queue.Count; if (queueSize == 0) { SubLabel.Text = "Downloading. No more items in the queue"; } else if (queueSize == 1) { SubLabel.Text = String.Format("Downloading. {0} item remaining to download", queueSize); } else { SubLabel.Text = string.Format("Downloading. {0} items remaining to download", queueSize); } ProgressBar.Progress = 0; } queueDownloader.OnStart += HandleQueueDownloaderOnStart; queueDownloader.OnProgress += HandleQueueDownloaderOnProgress; queueDownloader.OnEnd += HandleQueueDownloaderOnEnd; queueDownloader.OnNoMoreItems += HandleQueueDownloaderOnNoMoreItems; UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true; UIApplication.SharedApplication.IdleTimerDisabled = true; queueDownloader.Start(); }