-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotificationPopup.xaml.cs
More file actions
102 lines (90 loc) · 3.26 KB
/
NotificationPopup.xaml.cs
File metadata and controls
102 lines (90 loc) · 3.26 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media.Animation;
using System.Windows.Controls;
using System.Diagnostics;
namespace GoogleCalendarNotifier
{
public partial class NotificationPopup : Window
{
public event Action<TimeSpan?> OnSnooze;
public event Action OnDismiss;
public NotificationPopup()
{
InitializeComponent();
Loaded += NotificationPopup_Loaded;
// Position window in bottom right corner
this.WindowStartupLocation = WindowStartupLocation.Manual;
PositionWindow();
}
private void PositionWindow()
{
var screenWidth = SystemParameters.WorkArea.Width;
var screenHeight = SystemParameters.WorkArea.Height;
this.Left = screenWidth - this.Width - 20;
this.Top = screenHeight - this.Height - 20;
}
private void NotificationPopup_Loaded(object sender, RoutedEventArgs e)
{
// Fade in animation
this.Opacity = 0;
var fadeIn = new DoubleAnimation(0, 1, TimeSpan.FromSeconds(0.5));
this.BeginAnimation(UIElement.OpacityProperty, fadeIn);
}
public void ShowNotification(string title, string message)
{
TitleText.Text = title;
MessageText.Text = message;
Show();
Activate();
}
private void SnoozeButton_Click(object sender, RoutedEventArgs e)
{
var selectedItem = SnoozeComboBox.SelectedItem as ComboBoxItem;
if (selectedItem == null) return;
TimeSpan? snoozeTime = null;
string option = selectedItem.Content.ToString();
Debug.WriteLine($"Selected snooze option: {option}");
switch (option)
{
case "5 minutes":
snoozeTime = TimeSpan.FromMinutes(5);
break;
case "15 minutes":
snoozeTime = TimeSpan.FromMinutes(15);
break;
case "30 minutes":
snoozeTime = TimeSpan.FromMinutes(30);
break;
case "60 minutes":
snoozeTime = TimeSpan.FromMinutes(60);
break;
case "1 day":
snoozeTime = TimeSpan.FromDays(1);
break;
case "Never":
snoozeTime = TimeSpan.MaxValue;
Debug.WriteLine("Setting snooze to Never (MaxValue)");
break;
case "Event Time":
snoozeTime = TimeSpan.Zero;
Debug.WriteLine("Setting snooze to Event Time (Zero)");
break;
}
Debug.WriteLine($"Invoking OnSnooze with value: {snoozeTime}");
OnSnooze?.Invoke(snoozeTime);
Close();
}
private void DismissButton_Click(object sender, RoutedEventArgs e)
{
OnDismiss?.Invoke();
Close();
}
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
base.OnMouseLeftButtonDown(e);
DragMove();
}
}
}