-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogWorkForm.cs
More file actions
84 lines (73 loc) · 2.52 KB
/
Copy pathLogWorkForm.cs
File metadata and controls
84 lines (73 loc) · 2.52 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
using System;
using System.Globalization;
using Eto.Drawing;
using Eto.Forms;
namespace devtime
{
public class LogWorkForm : Dialog<bool>
{
public string Log { get; private set; } = "";
private readonly TextArea _textArea;
public LogWorkForm(string initialLog, string when)
{
Title = "Log work";
Icon = IconLoader.LoadIcon("log.png");
MinimumSize = new Size(268, 190);
Resizable = true;
_textArea = new TextArea { Text = initialLog, AcceptsTab = true, AcceptsReturn = true, Width = 232, Height = 115 };
string suffix;
if (DateTime.TryParseExact(when, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime date))
{
if (date == DateTime.Today)
{
suffix = "today";
}
else if (date == DateTime.Today.AddDays(-1))
{
suffix = "yesterday";
}
else if (date == DateTime.Today.AddDays(1))
{
suffix = "tomorrow";
}
else
{
suffix = "on " + when;
}
}
else
{
suffix = "on " + when;
}
var group = new GroupBox { Text = $"What did you do {suffix}?" };
group.Content = _textArea;
var okButton = new Button { Text = "OK" };
okButton.Click += (sender, e) => OkClick();
var cancelButton = new Button { Text = "Cancel" };
cancelButton.Click += (sender, e) => Close(false);
DefaultButton = okButton;
AbortButton = cancelButton;
var buttonLayout = new StackLayout
{
Orientation = Orientation.Horizontal,
Spacing = 5,
Items = { okButton, cancelButton }
};
Content = new TableLayout
{
Padding = new Padding(5),
Spacing = new Size(3, 3),
Rows =
{
new TableRow(new TableCell(group, true)) { ScaleHeight = true },
new TableRow(new StackLayout { HorizontalContentAlignment = HorizontalAlignment.Right, Items = { buttonLayout } })
}
};
}
private void OkClick()
{
Log = _textArea.Text ?? "";
Close(true);
}
}
}