-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
Copy pathRestartControl.xaml.cs
64 lines (56 loc) · 1.78 KB
/
RestartControl.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using CommunityToolkit.Mvvm.DependencyInjection;
using Files.Backend.Services.Settings;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using System;
using System.Diagnostics;
using Windows.System;
namespace Files.App.UserControls
{
public sealed partial class RestartControl : UserControl
{
public IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetRequiredService<IUserSettingsService>();
public RestartControl()
{
InitializeComponent();
}
public static readonly DependencyProperty ShowDialogProperty = DependencyProperty.Register(
"ShowDialog", typeof(bool), typeof(RestartControl), new PropertyMetadata(false, new PropertyChangedCallback(OnShowDialogPropertyChanged)));
public bool ShowDialog
{
get => (bool)GetValue(dp: ShowDialogProperty);
set => SetValue(ShowDialogProperty, value);
}
private static void OnShowDialogPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
var dialog = (RestartControl)sender;
if ((bool)e.NewValue)
{
dialog.RestartNotification.Show(10000);
}
else
{
dialog.RestartNotification.Dismiss();
}
}
public void Show()
{
RestartNotification.Show(10000);
}
public void Dismiss()
{
RestartNotification.Dismiss();
}
private async void YesButton_Click(object sender, RoutedEventArgs e)
{
UserSettingsService.AppSettingsService.RestoreTabsOnStartup = true; // Tells the app to restore tabs when it's next launched
App.SaveSessionTabs(); // Saves the open tabs
await Launcher.LaunchUriAsync(new Uri("files-uwp:")); // Launches a new instance of Files
Process.GetCurrentProcess().Kill(); // Closes the current instance
}
private void NoButton_Click(object sender, RoutedEventArgs e)
{
RestartNotification.Dismiss();
}
}
}