-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDateChange.cs
85 lines (74 loc) · 2.23 KB
/
DateChange.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
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
// Copyright (c) 2016 SolarLiner - Part of the TLE Orbiter Sceneraio Generator (TLEOSG)
using System;
using System.Windows.Forms;
namespace TLEOrbiter
{
public partial class DateChange : Form
{
public DateChange()
{
InitializeComponent();
//PickedTime = DateTime.UtcNow;
}
public DateChange(DateTime DT)
{
InitializeComponent();
PickedTime = DT;
}
public DateChange(double MJD)
{
InitializeComponent();
PickedTime = AOSP.Misc.GetTime(MJD);
}
private DateTime _dt;
private bool _updating;
public DateTime PickedTime
{
get
{
return _dt;
}
set
{
if (_updating) return;
if (value == _dt) return;
_dt = value;
_updating = true;
NU_Hours.Value = _dt.Hour;
NU_Minutes.Value = _dt.Minute;
NU_Seconds.Value = _dt.Second;
MC_Calendar.SetDate(_dt);
NU_MJD.Value = (decimal)PickedMJD;
_updating = false;
}
}
public double PickedMJD => AOSP.Misc.GetMJD(_dt);
private void UpdatePickedTime()
{
if (_updating) return;
DateTime d = MC_Calendar.SelectionStart.Date.Add(new TimeSpan((int)NU_Hours.Value, (int)NU_Minutes.Value, (int)NU_Seconds.Value));
PickedTime = d;
}
private void NU_ValueChanged(object sender, EventArgs e)
{
UpdatePickedTime();
}
private void MC_Calendar_DateChanged(object sender, DateRangeEventArgs e)
{
UpdatePickedTime();
}
private void NU_MJD_ValueChanged(object sender, EventArgs e)
{
if (_updating) return;
PickedTime = AOSP.Misc.GetTime((double)NU_MJD.Value);
}
private void BT_OK_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
}
private void BT_Cancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
}
}