This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddTimerModal.xaml.cs
50 lines (42 loc) · 1.6 KB
/
AddTimerModal.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
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace Timer
{
/// <summary>
/// Interaction logic for AddTimerModal.xaml
/// </summary>
public partial class AddTimerModal : UserControl
{
public AddTimerModal(MainWindow parent)
{
Parent = parent;
InitializeComponent();
}
private new readonly MainWindow Parent;
private void EventSetter_OnHandler(object sender, MouseWheelEventArgs e)
{
bool IsAdding = e.Delta > 0;
var input = (TextBox)sender;
var number = int.Parse(input.Text);
number = IsAdding ? number + 1 : number - 1;
number = number > 59 ? 0 : number;
number = number < 0 ? 59 : number;
input.Text = number < 10 ? "0" + number : number.ToString();
}
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
var hours = int.Parse(Hours.Text);
var minutes = int.Parse(Minutes.Text);
var seconds = int.Parse(Seconds.Text);
var title = Title.Text.Length == 0 ? "Без названия" : Title.Text;
if (hours == 0 && minutes == 0 && seconds == 0)
return;
Parent.AddTimerToList(new MainWindow.TimerStruct(hours, minutes, seconds, title));
Parent.CloseModal();
}
private void Title_OnMouseWheel(object sender, MouseWheelEventArgs e)
{ }
private void Background_OnMouseDown(object sender, MouseButtonEventArgs e) => Parent.CloseModal();
}
}