Ejemplo n.º 1
0
        private async void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            LoadingRect.Visibility    = Visibility.Visible;
            MainProgressRing.IsActive = true;
            var           items  = MainList.Items.Where(item => ((item as RouteListing)?.IsChecked).GetValueOrDefault(false)).Select(item => (RouteListing)item).ToArray();
            bool          sure   = false;
            MessageDialog dialog = new MessageDialog("If you delete these routes, you won't be able to see their schedules unless you are connected to the internet.", "Delete routes?");

            dialog.Commands.Add(new UICommand("Delete Routes", new UICommandInvokedHandler((cmd) => sure = true)));
            dialog.Commands.Add(new UICommand("Cancel", new UICommandInvokedHandler((cmd) => sure        = false)));
            await dialog.ShowAsync();

            if (sure)
            {
                await DownloadManager.DeleteRoutes(items);
            }
            MainProgressRing.IsActive = false;
            LoadingRect.Visibility    = Visibility.Collapsed;
        }
Ejemplo n.º 2
0
        private async void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            var           cancel = true;
            MessageDialog dialog = new MessageDialog("This will stop downloading and delete what was downloaded of the selected routes. Are you sure?", "Cancel Downloads?");

            dialog.Commands.Add(new UICommand("Yes", new UICommandInvokedHandler((cmd) => cancel = false)));
            dialog.Commands.Add(new UICommand("No", new UICommandInvokedHandler((cmd) => cancel  = true)));
            await dialog.ShowAsync();

            if (cancel)
            {
                return;
            }
            LoadingRect.Visibility    = Visibility.Visible;
            MainProgressRing.IsActive = true;
            DownloadsCancellationTokenSource.Cancel();
            DownloadsCancellationTokenSource = new CancellationTokenSource();
            await DownloadsTask;
            var   items = MainList.Items.Where(item => ((item as RouteListing)?.IsChecked).GetValueOrDefault(false)).Select(item => (RouteListing)item).ToArray();
            await DownloadManager.DeleteRoutes(items);

            MainProgressRing.IsActive = false;
            LoadingRect.Visibility    = Visibility.Collapsed;
        }