Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/MAUI/Maui.Samples/Helpers/SampleLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ public static async Task LoadSample(SampleInfo sampleInfo)
// Load offline data before showing the sample.
if (sampleInfo.OfflineDataItems != null && !await DataManager.HasSampleDataPresent(sampleInfo))
{
// Ask the user for permission before downloading.
bool download = await Application.Current.Windows[0].Page.DisplayAlert(
"Download Required",
"This sample requires data to be downloaded. Would you like to download it now?",
"Download", "Cancel");

if (!download)
{
SampleManager.Current.SelectedSample = null;
return;
}

CancellationTokenSource cancellationSource = new CancellationTokenSource();

// Show the wait page.
Expand Down
14 changes: 13 additions & 1 deletion src/WPF/WPF.Viewer/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,20 @@ private async Task SelectSample(SampleInfo selectedSample)

try
{
if (selectedSample.OfflineDataItems != null)
if (selectedSample.OfflineDataItems != null && !await DataManager.HasSampleDataPresent(selectedSample))
{
// Ask the user for permission before downloading.
var result = MessageBox.Show(
"This sample requires data to be downloaded. Would you like to download it now?",
"Download Required",
MessageBoxButton.YesNo, MessageBoxImage.Question);

if (result != MessageBoxResult.Yes)
{
SampleManager.Current.SelectedSample = null;
return;
}

CancellationTokenSource cancellationSource = new CancellationTokenSource();

// Show waiting page
Expand Down
14 changes: 13 additions & 1 deletion src/WinUI/ArcGIS.WinUI.Viewer/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,20 @@ private async Task SelectSample(SampleInfo selectedSample)

try
{
if (selectedSample.OfflineDataItems != null)
if (selectedSample.OfflineDataItems != null && !await DataManager.HasSampleDataPresent(selectedSample))
{
// Ask the user for permission before downloading.
var dialog = new MessageDialog2("This sample requires data to be downloaded. Would you like to download it now?", "Download Required");
dialog.Commands.Add(new Windows.UI.Popups.UICommand("Download"));
dialog.Commands.Add(new Windows.UI.Popups.UICommand("Cancel"));
var result = await dialog.ShowAsync();

if (result.Label != "Download")
{
SampleManager.Current.SelectedSample = null;
return;
}

CancellationTokenSource cancellationSource = new CancellationTokenSource();

// Show the waiting page
Expand Down
Loading