Skip to content

Commit

Permalink
Merge branch 'main' into file-scoped-namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewKeepCoding authored Dec 14, 2024
2 parents 5f4ff16 + 2b84b51 commit 523abd8
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 4 deletions.
39 changes: 35 additions & 4 deletions WinUIGallery/ControlPages/FilePickerPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public FilePickerPage()

private async void PickAFileButton_Click(object sender, RoutedEventArgs e)
{
//disable the button to avoid double-clicking
var senderButton = sender as Button;
senderButton.IsEnabled = false;

// Clear previous returned file name, if it exists, between iterations of this scenario
PickAFileOutputTextBlock.Text = "";

Expand Down Expand Up @@ -57,7 +61,7 @@ private async void PickAFileButton_Click(object sender, RoutedEventArgs e)
Run run2 = new Run();
run2.FontWeight = Microsoft.UI.Text.FontWeights.Bold;
run2.Text = file.Name;

span.Inlines.Add(run1);
span.Inlines.Add(run2);
PickAFileOutputTextBlock.Inlines.Add(span);
Expand All @@ -67,10 +71,17 @@ private async void PickAFileButton_Click(object sender, RoutedEventArgs e)
PickAFileOutputTextBlock.Text = "Operation cancelled.";
}

//re-enable the button
senderButton.IsEnabled = true;
UIHelper.AnnounceActionForAccessibility(sender as Button, PickAFileOutputTextBlock.Text, "FilePickedNotificationId");
}

private async void PickAPhotoButton_Click(object sender, RoutedEventArgs e)
{
//disable the button to avoid double-clicking
var senderButton = sender as Button;
senderButton.IsEnabled = false;

// Clear previous returned file name, if it exists, between iterations of this scenario
PickAPhotoOutputTextBlock.Text = "";

Expand Down Expand Up @@ -114,11 +125,17 @@ private async void PickAPhotoButton_Click(object sender, RoutedEventArgs e)
PickAPhotoOutputTextBlock.Text = "Operation cancelled.";
}

//re-enable the button
senderButton.IsEnabled = true;
UIHelper.AnnounceActionForAccessibility(sender as Button, PickAPhotoOutputTextBlock.Text, "PhotoPickedNotificationId");
}

private async void PickFilesButton_Click(object sender, RoutedEventArgs e)
{
//disable the button to avoid double-clicking
var senderButton = sender as Button;
senderButton.IsEnabled = false;

// Clear previous returned file name, if it exists, between iterations of this scenario
PickFilesOutputTextBlock.Text = "";

Expand Down Expand Up @@ -164,11 +181,17 @@ private async void PickFilesButton_Click(object sender, RoutedEventArgs e)
PickFilesOutputTextBlock.Text = "Operation cancelled.";
}

//re-enable the button
senderButton.IsEnabled = true;
UIHelper.AnnounceActionForAccessibility(sender as Button, PickFilesOutputTextBlock.Text, "FilesPickedNotificationId");
}

private async void PickFolderButton_Click(object sender, RoutedEventArgs e)
{
//disable the button to avoid double-clicking
var senderButton = sender as Button;
senderButton.IsEnabled = false;

// Clear previous returned file name, if it exists, between iterations of this scenario
PickFolderOutputTextBlock.Text = "";

Expand Down Expand Up @@ -211,11 +234,17 @@ private async void PickFolderButton_Click(object sender, RoutedEventArgs e)
PickFolderOutputTextBlock.Text = "Operation cancelled.";
}

//re-enable the button
senderButton.IsEnabled = true;
UIHelper.AnnounceActionForAccessibility(sender as Button, PickFolderOutputTextBlock.Text, "FolderPickedNotificationId");
}

private async void SaveFileButton_Click(object sender, RoutedEventArgs e)
{
//disable the button to avoid double-clicking
var senderButton = sender as Button;
senderButton.IsEnabled = false;

// Clear previous returned file name, if it exists, between iterations of this scenario
SaveFileOutputTextBlock.Text = "";

Expand All @@ -239,7 +268,7 @@ private async void SaveFileButton_Click(object sender, RoutedEventArgs e)
savePicker.SuggestedFileName = enteredFileName.Text;

// Open the picker for the user to pick a file
StorageFile file= await savePicker.PickSaveFileAsync();
StorageFile file = await savePicker.PickSaveFileAsync();
if (file != null)
{
// Prevent updates to the remote version of the file until we finish making changes and call CompleteUpdatesAsync.
Expand All @@ -256,7 +285,7 @@ private async void SaveFileButton_Click(object sender, RoutedEventArgs e)
}
// Another way to write a string to the file is to use this instead:
// await FileIO.WriteTextAsync(file, "Example file contents.");

// Let Windows know that we're finished changing the file so the other app can update the remote version of the file.
// Completing updates may require Windows to ask for user input.
FileUpdateStatus status = await CachedFileManager.CompleteUpdatesAsync(file);
Expand All @@ -278,6 +307,8 @@ private async void SaveFileButton_Click(object sender, RoutedEventArgs e)
SaveFileOutputTextBlock.Text = "Operation cancelled.";
}

//re-enable the button
senderButton.IsEnabled = true;
UIHelper.AnnounceActionForAccessibility(sender as Button, SaveFileOutputTextBlock.Text, "FileSavedNotificationId");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
private async void PickAFileButton_Click(object sender, RoutedEventArgs e)
{
//disable the button to avoid double-clicking
var senderButton = sender as Button;
senderButton.IsEnabled = false;

// Clear previous returned file name, if it exists, between iterations of this scenario
PickAFileOutputTextBlock.Text = "";

Expand Down Expand Up @@ -29,4 +33,7 @@
{
PickAFileOutputTextBlock.Text = "Operation cancelled.";
}

//re-enable the button
senderButton.IsEnabled = true;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
private async void PickAPhotoButton_Click(object sender, RoutedEventArgs e)
{
//disable the button to avoid double-clicking
var senderButton = sender as Button;
senderButton.IsEnabled = false;

// Clear previous returned file name, if it exists, between iterations of this scenario
PickAPhotoOutputTextBlock.Text = "";

Expand Down Expand Up @@ -32,4 +36,7 @@
{
PickAPhotoOutputTextBlock.Text = "Operation cancelled.";
}

//re-enable the button
senderButton.IsEnabled = true;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
private async void PickFilesButton_Click(object sender, RoutedEventArgs e)
{
//disable the button to avoid double-clicking
var senderButton = sender as Button;
senderButton.IsEnabled = false;

// Clear previous returned file name, if it exists, between iterations of this scenario
PickFilesOutputTextBlock.Text = "";

Expand Down Expand Up @@ -35,4 +39,7 @@
{
PickFilesOutputTextBlock.Text = "Operation cancelled.";
}

//re-enable the button
senderButton.IsEnabled = true;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
private async void PickFolderButton_Click(object sender, RoutedEventArgs e)
{
//disable the button to avoid double-clicking
var senderButton = sender as Button;
senderButton.IsEnabled = false;

// Clear previous returned file name, if it exists, between iterations of this scenario
PickFolderOutputTextBlock.Text = "";

Expand Down Expand Up @@ -30,4 +34,7 @@
{
PickFolderOutputTextBlock.Text = "Operation cancelled.";
}

//re-enable the button
senderButton.IsEnabled = true;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
private async void SaveFileButton_Click(object sender, RoutedEventArgs e)
{
//disable the button to avoid double-clicking
var senderButton = sender as Button;
senderButton.IsEnabled = false;

// Clear previous returned file name, if it exists, between iterations of this scenario
SaveFileOutputTextBlock.Text = "";

Expand Down Expand Up @@ -64,4 +68,7 @@
{
SaveFileOutputTextBlock.Text = "Operation cancelled.";
}

//re-enable the button
senderButton.IsEnabled = true;
}

0 comments on commit 523abd8

Please sign in to comment.