Beispiel #1
0
        /// <summary>
        /// Handles the <see cref="ToolStripControlHost.LostFocus"/> event.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// A <see cref="EventArgs"/> that contains the event data.
        /// </param>
        private void MonthCalendarHostLostFocus(object sender, EventArgs e)
        {
            if (this._isDropped)
            {
                this._buttonState = ComboButtonState.None;
                this.dropDown.Close(ToolStripDropDownCloseReason.AppFocusChange);
            }

            this.FocusChanged(this, EventArgs.Empty);
        }
Beispiel #2
0
 /// <summary>
 /// Handles the <see cref="EnhancedMonthCalendar.DateClicked"/> event.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="e">
 /// A <see cref="DateEventArgs"/> that contains the event data.
 /// </param>
 private void EnhancedMonthCalendarDateClicked(object sender, DateEventArgs e)
 {
     if (this.ClosePickerOnDayClick)
     {
         this._buttonState = ComboButtonState.Normal;
         this.dropDown.Close(ToolStripDropDownCloseReason.ItemClicked);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Handles the <see cref="EnhancedMonthCalendar.DateSelected"/> event.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="e">
 /// A <see cref="DateRangeEventArgs"/> that contains the event data.
 /// </param>
 private void EnhancedMonthCalendarDateSelected(object sender, DateRangeEventArgs e)
 {
     this._buttonState = ComboButtonState.Normal;
     this.dropDown.Close(ToolStripDropDownCloseReason.ItemClicked);
     this.dateTextBox.Date = e.Start;
 }
Beispiel #4
0
 /// <summary>Shows or closes the picker according to the current picker RequestState.</summary>
 internal void SwitchPickerState()
 {
     if (this._isDropped)
     {
         this._buttonState = ComboButtonState.Hot;
         this._isDropped = false;
         this.dropDown.Close(ToolStripDropDownCloseReason.CloseCalled);
         this.Focus();
     }
     else
     {
         if (this._buttonState == ComboButtonState.Pressed)
         {
             this._buttonState = ComboButtonState.Hot;
         }
         else if (this._buttonState == ComboButtonState.None)
         {
             this._buttonState = ComboButtonState.Hot;
         }
         else
         {
             this._buttonState = ComboButtonState.Pressed;
             this.Refresh();
             this.ShowDropDown();
         }
     }
 }
Beispiel #5
0
 /// <summary>
 /// Is raised when the toolstrip drop down is closing.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="e">
 /// A <see cref="ToolStripDropDownClosingEventArgs"/> instance which holds the event data.
 /// </param>
 private void DropDownClosing(object sender, ToolStripDropDownClosingEventArgs e)
 {
     if (this._cancelClosing)
     {
         this._cancelClosing = false;
         e.Cancel = true;
     }
     else
     {
         if (e.CloseReason == ToolStripDropDownCloseReason.CloseCalled)
         {
             this._buttonState = ComboButtonState.Hot;
             this.Invalidate();
         }
         else
         {
             this._isDropped = false;
         }
     }
 }
Beispiel #6
0
      /// <summary>
      /// Raises the <see cref="Control.LostFocus"/> event.
      /// </summary>
      /// <param name="e">A <see cref="EventArgs"/> that contains the event data.</param>
      protected override void OnLostFocus(EventArgs e)
      {
         if (!this.isDropped)
         {
            this.buttonState = ComboButtonState.Normal;

            this.Invalidate();
         }

         if (!this.Focused)
         {
            base.OnLostFocus(e);
         }
      }
Beispiel #7
0
      /// <summary>
      /// Raises the <see cref="Control.MouseMove"/> event.
      /// </summary>
      /// <param name="e">A <see cref="MouseEventArgs"/> that contains the event data.</param>
      protected override void OnMouseMove(MouseEventArgs e)
      {
         base.OnMouseMove(e);

         if (e.Button == MouseButtons.None && !this.isDropped)
         {
            ComboButtonState st = this.buttonState;

            this.buttonState = this.buttonBounds.Contains(e.Location) ?
               ComboButtonState.Hot : ComboButtonState.Normal;

            if (st != this.buttonState)
            {
               this.Invalidate();
            }
         }
      }
Beispiel #8
0
      /// <summary>
      /// Raises the mouse leave event.
      /// </summary>
      /// <param name="e">The event args.</param>
      protected override void OnMouseLeave(EventArgs e)
      {
         if (!this.isDropped)
         {
            this.buttonState = ComboButtonState.Normal;

            this.Invalidate();
         }

         base.OnMouseLeave(e);
      }
Beispiel #9
0
      /// <summary>
      /// Raises the mouse enter event.
      /// </summary>
      /// <param name="e">The event args.</param>
      protected override void OnMouseEnter(EventArgs e)
      {
         if (!this.isDropped)
         {
            this.buttonState = ComboButtonState.Hot;
            this.Refresh();
         }

         base.OnMouseEnter(e);
      }
Beispiel #10
0
      /// <summary>
      /// Draws the combobox button.
      /// </summary>
      /// <param name="g">The <see cref="Graphics"/> object used to draw.</param>
      /// <param name="rect">The <see cref="Rectangle"/> in which to draw.</param>
      /// <param name="buttonState">The <see cref="ComboButtonState"/>.</param>
      /// <param name="enabled">true if the button should be drawn enabled; false otherwise.</param>
      private static void DrawButton(Graphics g, Rectangle rect, ComboButtonState buttonState, bool enabled)
      {
         if (g == null || rect.IsEmpty || rect.Width != 14)
         {
            return;
         }

         ButtonColors btnColors = ColorArray[0];

         switch (buttonState)
         {
            case ComboButtonState.Hot:
               {
                  btnColors = ColorArray[1];

                  break;
               }

            case ComboButtonState.Pressed:
               {
                  btnColors = ColorArray[2];

                  break;
               }
         }

         using (LinearGradientBrush brush = new LinearGradientBrush(
            rect,
            MonthCalendarAbstractRenderer.GetGrayColor(enabled, btnColors.TL),
            MonthCalendarAbstractRenderer.GetGrayColor(enabled, btnColors.BL),
            LinearGradientMode.Vertical))
         {
            using (Pen p = new Pen(brush))
            {
               g.DrawLine(p, rect.X, rect.Y, rect.X, rect.Bottom);
            }
         }

         using (LinearGradientBrush brush = new LinearGradientBrush(
            rect,
            MonthCalendarAbstractRenderer.GetGrayColor(enabled, btnColors.BB),
            MonthCalendarAbstractRenderer.GetGrayColor(enabled, btnColors.BR),
            LinearGradientMode.Horizontal))
         {
            using (Pen p = new Pen(brush))
            {
               g.DrawLine(p, rect.X + 1, rect.Bottom, rect.Right, rect.Bottom);
            }
         }

         using (LinearGradientBrush brush = new LinearGradientBrush(
            rect,
            MonthCalendarAbstractRenderer.GetGrayColor(enabled, btnColors.TRR),
            MonthCalendarAbstractRenderer.GetGrayColor(enabled, btnColors.BR),
            LinearGradientMode.Vertical))
         {
            using (Pen p = new Pen(brush))
            {
               g.DrawLine(p, rect.Right, rect.Y, rect.Right, rect.Bottom);
            }
         }

         using (LinearGradientBrush brush = new LinearGradientBrush(
            rect,
            MonthCalendarAbstractRenderer.GetGrayColor(enabled, btnColors.TL),
            MonthCalendarAbstractRenderer.GetGrayColor(enabled, btnColors.TR),
            LinearGradientMode.Horizontal))
         {
            using (Pen p = new Pen(brush))
            {
               g.DrawLine(p, rect.X, rect.Y, rect.Right - 1, rect.Y);
            }
         }

         Rectangle r = rect;
         r.X++;
         r.Y++;
         r.Width--;
         r.Height--;

         using (LinearGradientBrush brush = new LinearGradientBrush(
            r,
            MonthCalendarAbstractRenderer.GetGrayColor(enabled, btnColors.BS),
            MonthCalendarAbstractRenderer.GetGrayColor(enabled, btnColors.BE),
            45f))
         {
            g.FillRectangle(brush, r);
         }

         r.X += 2;
         r.Y += (rect.Height / 2) - 3;
         r.Width = 9;
         r.Height = 6;

         using (Bitmap arrow = MonthCalendarControl.Properties.MonthCalendarResources.ComboArrowDown)
         {
            if (enabled)
            {
               g.DrawImage(arrow, r);
            }
            else
            {
               ControlPaint.DrawImageDisabled(g, arrow, r.X, r.Y, Color.Transparent);
            }
         }
      }