Repository navigation
Expand file tree
/
Copy pathNotificationWindow.xaml.cs
More file actions
58 lines (49 loc) · 1.59 KB
/
Copy pathNotificationWindow.xaml.cs
File metadata and controls
58 lines (49 loc) · 1.59 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
using System.Windows;
using System.Windows.Media;
using BackgroundClicker.Wpf.I18n;
namespace BackgroundClicker.Wpf
{
public enum NotificationResult
{
None,
Primary,
Secondary
}
public partial class NotificationWindow : Window
{
public NotificationResult Result { get; private set; }
public NotificationWindow(string message,
bool isError = false,
string primaryButtonText = null,
string secondaryButtonText = null)
{
InitializeComponent();
Result = NotificationResult.None;
MessageTextBlock.Text = message;
PrimaryButton.Content = primaryButtonText ?? Loc.T("notify.ok");
if (string.IsNullOrEmpty(secondaryButtonText))
{
SecondaryButton.Visibility = Visibility.Collapsed;
}
else
{
SecondaryButton.Visibility = Visibility.Visible;
SecondaryButton.Content = secondaryButtonText;
}
if (isError)
{
AccentBar.Fill = (Brush)FindResource("StateErrorBrush");
}
}
private void PrimaryButton_Click(object sender, RoutedEventArgs e)
{
Result = NotificationResult.Primary;
DialogResult = true;
}
private void SecondaryButton_Click(object sender, RoutedEventArgs e)
{
Result = NotificationResult.Secondary;
DialogResult = false;
}
}
}