-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindow.xaml.cs
More file actions
61 lines (53 loc) · 1.83 KB
/
Copy pathMainWindow.xaml.cs
File metadata and controls
61 lines (53 loc) · 1.83 KB
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
using System.Windows;
using SwitchifyPc.Core.Ui;
namespace SwitchifyPc.App;
public partial class MainWindow : Window
{
private readonly Action? openSettings;
private readonly Action? openUpdates;
private readonly Action? disconnectDevices;
private readonly Func<string, Task>? acceptPairingApproval;
private readonly Action<string>? rejectPairingApproval;
public MainWindow(
MainWindowViewModel? viewModel = null,
Action? openSettings = null,
Action? openUpdates = null,
Action? disconnectDevices = null,
Func<string, Task>? acceptPairingApproval = null,
Action<string>? rejectPairingApproval = null)
{
this.openSettings = openSettings;
this.openUpdates = openUpdates;
this.disconnectDevices = disconnectDevices;
this.acceptPairingApproval = acceptPairingApproval;
this.rejectPairingApproval = rejectPairingApproval;
InitializeComponent();
DataContext = viewModel ?? new MainWindowViewModel();
}
private void OpenSettings_Click(object sender, RoutedEventArgs e)
{
openSettings?.Invoke();
}
private void OpenUpdates_Click(object sender, RoutedEventArgs e)
{
openUpdates?.Invoke();
}
private void Disconnect_Click(object sender, RoutedEventArgs e)
{
disconnectDevices?.Invoke();
}
private async void AcceptPairing_Click(object sender, RoutedEventArgs e)
{
if (sender is FrameworkElement { Tag: string requestId } && acceptPairingApproval is not null)
{
await acceptPairingApproval(requestId);
}
}
private void RejectPairing_Click(object sender, RoutedEventArgs e)
{
if (sender is FrameworkElement { Tag: string requestId })
{
rejectPairingApproval?.Invoke(requestId);
}
}
}