#region Public variables
// this class has to have the specified hour, minute and second, as it says in msdn
- //public static readonly DateTime MaxDateTime = DateTime.Parse ("31 December 9998");//, 23:59:59");
public static readonly DateTime MaxDateTime = new DateTime (9998, 12, 31, 23, 59, 59);
public static readonly DateTime MinDateTime = new DateTime (1753, 1, 1);
month_calendar.DateSelected += new DateRangeEventHandler (MonthCalendarDateSelectedHandler);
KeyPress += new KeyPressEventHandler (KeyPressHandler);
- LostFocus += new EventHandler (LostFocusHandler);
+// LostFocus += new EventHandler (LostFocusHandler);
MouseDown += new MouseEventHandler (MouseDownHandler);
Paint += new PaintEventHandler (PaintHandler);
+ SetStyle (ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
}
#endregion
if (custom_format != value) {
custom_format = value;
if (this.Format == DateTimePickerFormat.Custom) {
- // invalidate the value inside this control
- this.Invalidate (date_area_rect);
+ // TODO: change the text value of the dtp
}
}
}
public LeftRightAlignment DropDownAlign {
set {
if (drop_down_align != value) {
- drop_down_align = value;
+ drop_down_align = value;
}
}
get {
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string Text {
set {
+ // TODO: if the format is a custom format we need to do a custom parse here
DateTime parsed_value = DateTime.Parse (value);
if (date_value != parsed_value) {
Value = parsed_value;
- }
+ }
+ text = FormatValue ();
}
get {
return text;
location.X = parent_control_rect.Right - child_size.Width;
}
- Point screen_location = PointToScreen (location);
+ Point screen_location = PointToScreen (location);
// TODO: enable this part when screen comes into the classes
/*
Rectangle working_area = Screen.FromControl(this).WorkingArea;
align_area,
month_calendar.Size,
(this.DropDownAlign == LeftRightAlignment.Left));
-
month_calendar.Show ();
month_calendar.Focus ();
+ month_calendar.Capture = true;
// fire any registered events
if (this.DropDown != null) {
{
this.is_drop_down_visible = false;
Invalidate (drop_down_arrow_rect);
+ month_calendar.Capture = false;
if (month_calendar.Visible) {
month_calendar.Hide ();
}
e.Handled = true;
}
- // if we lose focus and the drop down is up, then close it
- private void LostFocusHandler (object sender, EventArgs e)
- {
- if (is_drop_down_visible && !month_calendar.Focused) {
- this.HideMonthCalendar ();
- }
- }
+// // if we lose focus and the drop down is up, then close it
+// private void LostFocusHandler (object sender, EventArgs e)
+// {
+// if (is_drop_down_visible && !month_calendar.Focused) {
+// this.HideMonthCalendar ();
+// }
+// }
// fired when a user clicks on the month calendar to select a date
private void MonthCalendarDateSelectedHandler (object sender, DateRangeEventArgs e)
{
this.Value = e.Start.Date.Add (this.Value.TimeOfDay);
this.HideMonthCalendar ();
- this.Focus ();
- System.Console.WriteLine("MonthCalendarDateSelectedHandler");
+ this.Focus ();
}
// to check if the mouse has come down on this control
DropDownMonthCalendar ();
} else {
// mouse down on this control anywhere else collapses it
- if (is_drop_down_visible) {
- System.Console.WriteLine("hiding cause of mouse down");
+ if (is_drop_down_visible) {
HideMonthCalendar ();
}
}
ret_value = date_value.ToShortDateString ();
break;
case DateTimePickerFormat.Time:
- ret_value = date_value.ToShortDateString ();
+ ret_value = date_value.ToLongTimeString ();
break;
default:
ret_value = date_value.ToLongDateString ();
// REMAINING TODO:
// - get the date_cell_size and title_size to be pixel perfect match of SWF
// - show the year spin control
-// - remove comments around the "if (this.Capture) {" in the TimerHandler method
using System;
using System.Collections;
SetUpContextMenu ();
// event handlers
- LostFocus += new EventHandler (LostFocusHandler);
+// LostFocus += new EventHandler (LostFocusHandler);
timer.Tick += new EventHandler (TimerHandler);
MouseMove += new MouseEventHandler (MouseMoveHandler);
MouseDown += new MouseEventHandler (MouseDownHandler);
// raised on the timer, for mouse hold clicks
private void TimerHandler (object sender, EventArgs e) {
-// NOTE: i have diabled the if this.Capture because it doesn't work
-// when this.Capture works then need to renable the if in this section
-// // now find out which area was click
+ // now find out which area was click
if (this.Capture) {
HitTestInfo hti = this.HitTest (this.PointToClient (MousePosition));
// see if it was clicked on the prev or next mouse
this.is_date_clicked = false;
}
- // need when in windowed mode
- private void LostFocusHandler (object sender, EventArgs e)
- {
- if (this.owner != null) {
- if (this.Visible) {
- this.owner.HideMonthCalendar ();
- }
- }
- }
+// // need when in windowed mode
+// private void LostFocusHandler (object sender, EventArgs e)
+// {
+// if (this.owner != null) {
+// if (this.Visible) {
+// this.owner.HideMonthCalendar ();
+// }
+// }
+// }
// occurs when mouse moves around control, used for selection
private void MouseMoveHandler (object sender, MouseEventArgs e) {
timer.Stop ();
timer.Enabled = false;
}
+
+ Point point = new Point (e.X, e.Y);
+ // figure out if we are in drop down mode and a click happened outside us
+ if (this.owner != null) {
+ if (!this.ClientRectangle.Contains (point)) {
+ this.owner.HideMonthCalendar ();
+ return;
+ }
+ }
+
//establish where was hit
- HitTestInfo hti = this.HitTest(e.X, e.Y);
+ HitTestInfo hti = this.HitTest(point);
switch (hti.HitArea) {\r
case HitArea.PrevMonthButton:
case HitArea.NextMonthButton:
default:
this.is_previous_clicked = false;
this.is_next_clicked = false;
- this.is_date_clicked = false;
+ this.is_date_clicked = false;
break;
}
}