protected override void OnMouseDown(MouseEventArgs mevent) { if (mevent.Button == MouseButtons.Left) { state = NuiBlueControlState.Down; } base.OnMouseDown(mevent); }
protected override void OnEnabledChanged(EventArgs e) { if (Enabled) { state = NuiBlueControlState.Normal; } else { state = NuiBlueControlState.Disabled; } base.OnEnabledChanged(e); }
protected override void OnPaint(PaintEventArgs pevent) { base.OnPaint(pevent); base.OnPaintBackground(pevent); Graphics g = pevent.Graphics; g.SmoothingMode = SmoothingMode.AntiAlias; g.InterpolationMode = InterpolationMode.HighQualityBicubic; Rectangle checkRect, textRect; CalculateRect(out checkRect, out textRect); if (Enabled == false) { state = NuiBlueControlState.Disabled; } switch (state) { case NuiBlueControlState.Hover: case NuiBlueControlState.Down: DrawHoverCheckRect(g, checkRect); break; case NuiBlueControlState.Disabled: DrawDisabledCheckRect(g, checkRect); break; default: DrawNormalCheckRect(g, checkRect); break; } Color textColor = (Enabled == true) ? ForeColor : SystemColors.GrayText; TextRenderer.DrawText( g, Text, Font, textRect, textColor, MethodHelper.GetTextFormatFlags(TextAlign, RightToLeft == RightToLeft.Yes)); }
protected override void OnMouseUp(MouseEventArgs mevent) { if (mevent.Button == MouseButtons.Left) { if (ClientRectangle.Contains(mevent.Location)) { state = NuiBlueControlState.Hover; } else { state = NuiBlueControlState.Normal; } } base.OnMouseUp(mevent); }
protected override void OnMouseLeave(EventArgs e) { state = NuiBlueControlState.Normal; base.OnMouseLeave(e); }
protected override void OnPaint(PaintEventArgs pevent) { base.OnPaint(pevent); Graphics g = pevent.Graphics; g.SmoothingMode = SmoothingMode.AntiAlias; g.InterpolationMode = InterpolationMode.HighQualityBilinear; Rectangle imageRect, textRect; CalculateRect(out imageRect, out textRect); if (!Enabled) { state = NuiBlueControlState.Disabled; } switch (state) { case NuiBlueControlState.Normal: Render.DrawNineRectEx( g, normalImg, ClientRectangle, new Rectangle(0, 0, normalImg.Width, normalImg.Height)); break; case NuiBlueControlState.Hover: Render.DrawNineRectEx( g, hightImg, ClientRectangle, new Rectangle(0, 0, hightImg.Width, hightImg.Height)); break; case NuiBlueControlState.Focus: Render.DrawNineRectEx( g, focusImg, ClientRectangle, new Rectangle(0, 0, focusImg.Width, focusImg.Height)); break; case NuiBlueControlState.Down: Render.DrawNineRectEx( g, downImg, ClientRectangle, new Rectangle(0, 0, downImg.Width, downImg.Height)); break; case NuiBlueControlState.Disabled: DrawDisabledButton(g); break; default: break; } if (Image != null) { g.DrawImage(Image, imageRect, 0, 0, Image.Width, Image.Height, GraphicsUnit.Pixel); } Color textColor = Enabled ? ForeColor : SystemColors.GrayText; TextRenderer.DrawText( g, Text, Font, textRect, textColor, GetTextFormatFlags(TextAlign, RightToLeft == RightToLeft.Yes)); }
protected override void OnMouseLeave(EventArgs e) { if (state == NuiBlueControlState.Hover && Focused) { state = NuiBlueControlState.Focus; } else if (state == NuiBlueControlState.Focus) { state = NuiBlueControlState.Focus; } else { state = NuiBlueControlState.Normal; } this.Invalidate(); base.OnMouseLeave(e); }
protected override void OnMouseDown(MouseEventArgs e) { if (e.Button == MouseButtons.Left) { state = NuiBlueControlState.Down; } Invalidate(); base.OnMouseDown(e); }
private void WmPaint(ref Message m) { Graphics g = Graphics.FromHwnd(base.Handle); g.SmoothingMode = SmoothingMode.AntiAlias; if (!Enabled) { state = NuiBlueControlState.Disabled; } switch (state) { case NuiBlueControlState.Normal: DrawNormalTextBox(g); break; case NuiBlueControlState.Hover: DrawHoverTextBox(g); break; case NuiBlueControlState.Focus: DrawFocusTextBox(g); break; case NuiBlueControlState.Disabled: DrawDisabledTextBox(g); break; default: break; } if (Text.Length == 0 && !string.IsNullOrEmpty(EmptyTextTip) && !Focused) { TextRenderer.DrawText(g, EmptyTextTip, Font, ClientRectangle, EmptyTextTipColor, GetTextFormatFlags(TextAlign, RightToLeft == RightToLeft.Yes)); } }
protected override void OnMouseDown(MouseEventArgs mevent) { if (mevent.Button == MouseButtons.Left) { state = NuiBlueControlState.Hover; } this.Invalidate(); base.OnMouseDown(mevent); }
protected override void OnLostFocus(EventArgs e) { state = NuiBlueControlState.Normal; base.OnLostFocus(e); }
protected override void OnPaint(PaintEventArgs pevent) { base.OnPaint(pevent); base.OnPaintBackground(pevent); Graphics g = pevent.Graphics; g.SmoothingMode = SmoothingMode.AntiAlias; g.InterpolationMode = InterpolationMode.HighQualityBicubic; const int IMAGE_WIDTH = 15; const int IMAGE_HEIGHT = 15; Rectangle imageRect = new Rectangle(0, 3, IMAGE_WIDTH, IMAGE_HEIGHT); Rectangle textRect = new Rectangle(imageRect.Right + 2, 0, Width - imageRect.Right - 4, Height); int startX = 0; if (Enabled == false) { state = NuiBlueControlState.Disabled; } switch (state) { case NuiBlueControlState.Normal:startX = this.Checked ? 4 * IMAGE_WIDTH : 0;break; case NuiBlueControlState.Hover:startX = this.Checked ? 5 * IMAGE_WIDTH : 1 * IMAGE_WIDTH;break; case NuiBlueControlState.Down:startX = this.Checked ? 6 * IMAGE_WIDTH : 2 * IMAGE_WIDTH;break; case NuiBlueControlState.Focus:startX = this.Checked ? 5 * IMAGE_WIDTH : 1 * IMAGE_WIDTH;break; case NuiBlueControlState.Disabled:startX = this.Checked ? 7 * IMAGE_WIDTH : 3 * IMAGE_WIDTH;break; default:break; } g.DrawImage(resourceImage, imageRect, new Rectangle(startX, 0, IMAGE_WIDTH, IMAGE_HEIGHT), GraphicsUnit.Pixel); Color textColor = (Enabled == true) ? ForeColor : SystemColors.GrayText; TextRenderer.DrawText( g, Text, Font, textRect, textColor, MethodHelper.GetTextFormatFlags(TextAlign, RightToLeft == RightToLeft.Yes)); }
protected override void OnMouseUp(MouseEventArgs e) { if (e.Button == MouseButtons.Left) { state = ClientRectangle.Contains(e.Location) ? NuiBlueControlState.Hover : NuiBlueControlState.Normal; } Invalidate(); base.OnMouseUp(e); }
protected override void OnMouseEnter(EventArgs e) { //show tool tip if (ToolTipText != string.Empty) { HideToolTip(); ShowTooTip(ToolTipText); } state = NuiBlueControlState.Hover; Invalidate(); base.OnMouseEnter(e); }
protected override void OnGotFocus(EventArgs e) { state = NuiBlueControlState.Focus; this.Invalidate(); base.OnGotFocus(e); }
protected override void OnMouseEnter(EventArgs e) { state = NuiBlueControlState.Hover; base.OnMouseEnter(e); }
protected override void OnLostFocus(EventArgs e) { state = NuiBlueControlState.Normal; Invalidate(); holdingSpace = false; base.OnLostFocus(e); }