-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathDeviceConnectionPrompt.xaml.cs
49 lines (40 loc) · 1.62 KB
/
DeviceConnectionPrompt.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
using System.Windows;
namespace Conduit
{
/// <summary>
/// Interaction logic for DeviceConnectionPrompt.xaml
/// </summary>
public partial class DeviceConnectionPrompt : Window
{
private const string PROMPT =
"A DEVICE running BROWSER is trying to control your League client remotely using Mimic. Do you want to allow access?\r\n\r\nPressing allow will remember your choice and not prompt the next time. Only press allow if you recognize the device.";
public delegate void HandleConnectionResultDelegate(bool result);
public DeviceConnectionPrompt(string device, string browser, HandleConnectionResultDelegate handler)
{
InitializeComponent();
// Add device name to the prompt.
this.TextField.Text = PROMPT.Replace("DEVICE", device).Replace("BROWSER", browser);
// If deny is pressed, close and return false.
bool returned = false;
this.DenyButton.Click += (sender, args) =>
{
returned = true;
Close();
handler(false);
};
// If allow is pressed, close and return true.
this.AllowButton.Click += (sender, args) =>
{
returned = true;
Close();
handler(true);
};
// If the window is manually closed, treat it as a denial.
this.Closed += (sender, args) =>
{
// Only handle this if the close wasn't caused by us.
if (!returned) handler(false);
};
}
}
}