Skip to content

Commit

Permalink
InfoPage sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
KimihikoAkayasaki committed Mar 12, 2023
1 parent 2af9119 commit 2603b8f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Amethyst/Pages/Info.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
CloseButtonClick="EndingTeachingTip_CloseButtonClick" />

<Flyout x:Name="CommandFlyout" ShowMode="TransientWithDismissOnPointerMoveAway"
Placement="Top" Opening="CommandFlyout_Opening">
Placement="Top" Opening="CommandFlyout_Opening" Closing="CommandFlyout_Closing">
<Flyout.FlyoutPresenterStyle>
<Style TargetType="FlyoutPresenter">
<Setter Property="MinHeight" Value="60" />
Expand Down Expand Up @@ -259,7 +259,7 @@

<Page.Resources>
<ResourceDictionary>
<Flyout x:Name="TelemetryFlyout">
<Flyout x:Name="TelemetryFlyout" Opening="TelemetryFlyout_Opening" Closing="TelemetryFlyout_Closing">
<Flyout.FlyoutPresenterStyle>
<Style TargetType="FlyoutPresenter">
<Setter Property="MinWidth" Value="470" />
Expand Down
22 changes: 22 additions & 0 deletions Amethyst/Pages/Info.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ private async void CommandTextBox_KeyDown(object sender, KeyRoutedEventArgs e)
{
if (_commandConfirmLocked) return;
_commandConfirmLocked = true; // Don't re-accept now!
AppSounds.PlayAppSound(AppSounds.AppSoundType.Invoke);

// Check starts-with first : toast?
if (((TextBox)sender).Text.ToLowerInvariant().StartsWith("toast "))
Expand Down Expand Up @@ -444,15 +445,21 @@ private void SetCommandText(string text)
private void CommandFlyout_Opening(object sender, object e)
{
SetCommandText("Type command:");
AppSounds.PlayAppSound(AppSounds.AppSoundType.Show);
}

private async void TelemetryToggleSwitch_Toggled(object sender, RoutedEventArgs e)
{
if (!_infoPageLoadedOnce) return;
AppData.Settings.IsTelemetryEnabled = (sender as ToggleSwitch)?.IsOn ?? true;
AppData.Settings.SaveSettings(); // Save our made changes

await Analytics.SetEnabledAsync(AppData.Settings.IsTelemetryEnabled);
await Crashes.SetEnabledAsync(AppData.Settings.IsTelemetryEnabled);

AppSounds.PlayAppSound(AppData.Settings.IsTelemetryEnabled
? AppSounds.AppSoundType.ToggleOn
: AppSounds.AppSoundType.ToggleOff);
}

private void TelemetryTextBlock_Tapped(object sender, TappedRoutedEventArgs e)
Expand All @@ -463,4 +470,19 @@ private void TelemetryTextBlock_Tapped(object sender, TappedRoutedEventArgs e)
ShowMode = FlyoutShowMode.TransientWithDismissOnPointerMoveAway
});
}

private void TelemetryFlyout_Opening(object sender, object e)
{
AppSounds.PlayAppSound(AppSounds.AppSoundType.Show);
}

private void TelemetryFlyout_Closing(FlyoutBase sender, FlyoutBaseClosingEventArgs args)
{
AppSounds.PlayAppSound(AppSounds.AppSoundType.Hide);
}

private void CommandFlyout_Closing(FlyoutBase sender, FlyoutBaseClosingEventArgs args)
{
AppSounds.PlayAppSound(AppSounds.AppSoundType.Hide);
}
}

0 comments on commit 2603b8f

Please sign in to comment.