/// <summary> /// Sets the next date part specified by the <paramref name="left"/>. /// </summary> /// <param name="left">true for selecting the next left date part; false for the next right date part.</param> private void SetDatePart(bool left) { int index = -1; switch (this.selectedPart) { case SelectedDatePart.Day: { index = this.dayPartIndex; break; } case SelectedDatePart.Month: { index = this.monthPartIndex; break; } case SelectedDatePart.Year: { index = this.yearPartIndex; break; } } if (index != -1) { this.selectedPart = this.GetNextSelectedPart(index, left); } this.Refresh(); }
/// <summary> /// Raises the <see cref="System.Windows.Forms.Control.MouseDown"/> event. /// </summary> /// <param name="e">A <see cref="MouseEventArgs"/> that contains the event data.</param> protected override void OnMouseDown(MouseEventArgs e) { this.Focus(); var dayDist = (int)Math.Min(Math.Abs(this.dayBounds.Left - e.Location.X), Math.Abs(this.dayBounds.Right - e.Location.X)); var monthDist = (int)Math.Min(Math.Abs(this.monthBounds.Left - e.Location.X), Math.Abs(this.monthBounds.Right - e.Location.X)); var yearDist = (int)Math.Min(Math.Abs(this.yearBounds.Left - e.Location.X), Math.Abs(this.yearBounds.Right - e.Location.X)); var min = Math.Min(dayDist, Math.Min(monthDist, yearDist)); if (this.dayBounds.Contains(e.Location) || min == dayDist) { this.selectedPart = SelectedDatePart.Day; } else if (this.monthBounds.Contains(e.Location) || min == monthDist) { this.selectedPart = SelectedDatePart.Month; } else if (this.yearBounds.Contains(e.Location) || min == yearDist) { this.selectedPart = SelectedDatePart.Year; } this.Refresh(); base.OnMouseDown(e); }
/// <summary> /// Raises the <see cref="System.Windows.Forms.Control.LostFocus"/> event. /// </summary> /// <param name="e">A <see cref="EventArgs"/> that contains the event data.</param> protected override void OnLostFocus(EventArgs e) { base.OnLostFocus(e); this.selectedPart = SelectedDatePart.None; this.Refresh(); }
/// <summary> /// Raises the <see cref="System.Windows.Forms.Control.MouseDown"/> event. /// </summary> /// <param name="e">A <see cref="MouseEventArgs"/> that contains the event data.</param> protected override void OnMouseDown(MouseEventArgs e) { this.Focus(); if (this.dayBounds.Contains(e.Location)) { this.selectedPart = SelectedDatePart.Day; } else if (this.monthBounds.Contains(e.Location)) { this.selectedPart = SelectedDatePart.Month; } else if (this.yearBounds.Contains(e.Location)) { this.selectedPart = SelectedDatePart.Year; } this.Refresh(); base.OnMouseDown(e); }
/// <summary> /// Sets the next date part specified by the <paramref name="left"/>. /// </summary> /// <param name="left">true for selecting the next left date part; false for the next right date part.</param> private void SetDatePart(bool left) { int index = -1; switch (this.selectedPart) { case SelectedDatePart.Day: { index = this.dayPartIndex; break; } case SelectedDatePart.Month: { index = this.monthPartIndex; break; } case SelectedDatePart.Year: { index = this.yearPartIndex; break; } } if (index != -1) { this.selectedPart = this.GetNextSelectedPart(index, left); } this.Refresh(); }
/// <summary> /// Raises the <see cref="System.Windows.Forms.Control.LostFocus"/> event. /// </summary> /// <param name="e">A <see cref="EventArgs"/> that contains the event data.</param> protected override void OnLostFocus(EventArgs e) { base.OnLostFocus(e); this.selectedPart = SelectedDatePart.None; this.Refresh(); }
/// <summary> /// Raises the <see cref="System.Windows.Forms.Control.MouseDown"/> event. /// </summary> /// <param name="e">A <see cref="MouseEventArgs"/> that contains the event data.</param> protected override void OnMouseDown(MouseEventArgs e) { this.Focus(); var dayDist = (int)Math.Min(Math.Abs(this.dayBounds.Left - e.Location.X), Math.Abs(this.dayBounds.Right - e.Location.X)); var monthDist = (int)Math.Min(Math.Abs(this.monthBounds.Left - e.Location.X), Math.Abs(this.monthBounds.Right - e.Location.X)); var yearDist = (int)Math.Min(Math.Abs(this.yearBounds.Left - e.Location.X), Math.Abs(this.yearBounds.Right - e.Location.X)); var min = Math.Min(dayDist, Math.Min(monthDist, yearDist)); if (this.dayBounds.Contains(e.Location) || min == dayDist) { this.selectedPart = SelectedDatePart.Day; } else if (this.monthBounds.Contains(e.Location) || min == monthDist) { this.selectedPart = SelectedDatePart.Month; } else if (this.yearBounds.Contains(e.Location) || min == yearDist) { this.selectedPart = SelectedDatePart.Year; } this.Refresh(); base.OnMouseDown(e); }
/// <summary> /// Raises the <see cref="System.Windows.Forms.Control.GotFocus"/> event. /// </summary> /// <param name="e"> /// A <see cref="EventArgs"/> that contains the event data. /// </param> protected override void OnGotFocus(EventArgs e) { base.OnGotFocus(e); this._selectedPart = SelectedDatePart.Day; this.Refresh(); }