simplify notification

This commit is contained in:
Jakob 2023-07-14 22:03:26 +02:00
parent 726adc7193
commit 452790d923
5 changed files with 17 additions and 22 deletions

View file

@ -31,25 +31,16 @@ namespace EnvyUpdate
// TODO: Watch for theme changes and dynamically update
// Listen to notification activation
ToastNotificationManagerCompat.OnActivated += toastArgs =>
{
// Obtain the arguments from the notification
ToastArguments args = ToastArguments.Parse(toastArgs.Argument);
ToastNotificationManagerCompat.OnActivated += ToastNotificationManagerCompat_OnActivated;
}
// Need to dispatch to UI thread if performing UI operations
Application.Current.Dispatcher.Invoke(delegate
{
switch (args.Get("action"))
{
case "download":
Process.Start(Util.GetGpuUrl());
break;
default:
Util.ShowMain();
break;
}
});
};
private void ToastNotificationManagerCompat_OnActivated(ToastNotificationActivatedEventArgsCompat e)
{
// Need to dispatch to UI thread if performing UI operations
Application.Current.Dispatcher.Invoke(delegate
{
Util.ShowMain();
});
}
}
}

View file

@ -48,6 +48,7 @@
<ui:Button x:Name="buttonSkipVersion" Margin="8,0,0,0" Grid.Column="1" Appearance="Secondary" Icon="ArrowForward24" Visibility="Collapsed" ToolTip="{x:Static p:Resources.ui_skipversion}" Click="buttonSkipVersion_Click" />
<ui:Button x:Name="buttonDownload" Margin="8,0,0,0" MinWidth="100" Grid.Column="2" Appearance="Primary" Icon="ArrowDownload24" Visibility="Collapsed" Click="buttonDownload_Click" />
<ui:Button x:Name="buttonInstall" Margin="8,0,0,0" MinWidth="100" Grid.Column="2" Appearance="Primary" Icon="AppsAddIn24" Visibility="Collapsed" Click="buttonInstall_Click" />
</Grid>
<ProgressBar x:Name="progressbarDownload" Grid.Row="2" Value="0" Visibility="Collapsed"/>

View file

@ -378,6 +378,8 @@ namespace EnvyUpdate
{
Application.Current.Dispatcher.Invoke(new Action(() => {
showSnackbar(Wpf.Ui.Common.ControlAppearance.Success, Wpf.Ui.Common.SymbolRegular.CheckmarkCircle24, Properties.Resources.info_download_success, Properties.Resources.info_download_success_title);
buttonDownload.Visibility = Visibility.Collapsed;
buttonInstall.Visibility = Visibility.Visible;
}));
if (File.Exists(Path.Combine(GlobalVars.exedirectory, "nvidia-installer.exe")))
File.Delete(Path.Combine(GlobalVars.exedirectory, "nvidia-installer.exe"));
@ -391,6 +393,10 @@ namespace EnvyUpdate
}));
}
}
private void buttonInstall_Click(object sender, RoutedEventArgs e)
{
}
private void showSnackbar (Wpf.Ui.Common.ControlAppearance appearance, Wpf.Ui.Common.SymbolRegular icon, string message = "", string title = "")
{

View file

@ -11,7 +11,7 @@
ExtendsContentIntoTitleBar="True"
WindowBackdropType="Mica"
Title="EnvyUpdate" MinHeight="450" Height="450" MinWidth="600" Width="600" Icon="icon.ico" StateChanged="Window_StateChanged" Closing="Window_Closing" ResizeMode="CanMinimize" Activated="UiWindow_Activated" WindowStyle="None">
Title="EnvyUpdate" MinHeight="500" Height="500" MinWidth="600" Width="600" Icon="icon.ico" StateChanged="Window_StateChanged" Closing="Window_Closing" ResizeMode="CanMinimize" Activated="UiWindow_Activated" WindowStyle="None">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />

View file

@ -8,9 +8,6 @@ namespace EnvyUpdate
{
var toast = new ToastContentBuilder();
toast.AddText(Properties.Resources.update_popup_message);
toast.AddButton(new ToastButton()
.SetContent("Download")
.AddArgument("action", "download"));
toast.Show();
}
}