2011-12-17 05:22:40 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using System.Drawing.Drawing2D;
|
|
|
|
|
|
|
|
|
|
namespace ArdupilotMega
|
|
|
|
|
{
|
|
|
|
|
class MyButton : Button
|
|
|
|
|
{
|
|
|
|
|
bool mouseover = false;
|
|
|
|
|
bool mousedown = false;
|
|
|
|
|
|
2012-02-20 07:30:47 -04:00
|
|
|
|
bool inOnPaint = false;
|
|
|
|
|
|
2012-03-06 06:27:43 -04:00
|
|
|
|
public Color BGGradTop = Color.FromArgb(0x94, 0xc1, 0x1f);
|
|
|
|
|
|
|
|
|
|
public Color BGGradBot = Color.FromArgb(0xcd, 0xe2, 0x96);
|
|
|
|
|
|
2012-03-09 11:18:12 -04:00
|
|
|
|
// i want to ignore forecolor
|
|
|
|
|
public Color TextColor = Color.FromArgb(0x40, 0x57, 0x04);
|
2012-03-06 06:27:43 -04:00
|
|
|
|
|
|
|
|
|
public Color Outline = Color.FromArgb(0x79, 0x94, 0x29);
|
|
|
|
|
|
2011-12-17 05:22:40 -04:00
|
|
|
|
protected override void OnPaint(PaintEventArgs pevent)
|
|
|
|
|
{
|
|
|
|
|
//base.OnPaint(pevent);
|
|
|
|
|
|
2012-02-20 07:30:47 -04:00
|
|
|
|
if (inOnPaint)
|
|
|
|
|
return;
|
2011-12-17 05:22:40 -04:00
|
|
|
|
|
2012-02-20 07:30:47 -04:00
|
|
|
|
inOnPaint = true;
|
2011-12-17 05:22:40 -04:00
|
|
|
|
|
2012-02-20 07:30:47 -04:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Graphics gr = pevent.Graphics;
|
2011-12-17 05:22:40 -04:00
|
|
|
|
|
2012-02-20 07:30:47 -04:00
|
|
|
|
// gr.SmoothingMode = SmoothingMode.AntiAlias;
|
2011-12-17 05:22:40 -04:00
|
|
|
|
|
2012-02-20 07:30:47 -04:00
|
|
|
|
Rectangle outside = new Rectangle(0, 0, this.Width, this.Height);
|
2011-12-17 05:22:40 -04:00
|
|
|
|
|
2012-03-06 06:27:43 -04:00
|
|
|
|
LinearGradientBrush linear = new LinearGradientBrush(outside, BGGradTop, BGGradBot, LinearGradientMode.Vertical);
|
2011-12-17 05:22:40 -04:00
|
|
|
|
|
2012-03-06 06:27:43 -04:00
|
|
|
|
Pen mypen = new Pen(Outline, 2);
|
2012-02-20 07:30:47 -04:00
|
|
|
|
/*
|
|
|
|
|
gr.FillRectangle(new SolidBrush(Color.FromArgb(0x26, 0x27, 0x28)), outside);
|
2011-12-17 05:22:40 -04:00
|
|
|
|
|
2012-02-20 07:30:47 -04:00
|
|
|
|
GraphicsPath outline = new GraphicsPath();
|
2011-12-17 05:22:40 -04:00
|
|
|
|
|
2012-02-20 07:30:47 -04:00
|
|
|
|
float wid = this.Height / 5f;
|
|
|
|
|
float widright = wid + 1;
|
2011-12-17 05:22:40 -04:00
|
|
|
|
|
2012-02-20 07:30:47 -04:00
|
|
|
|
// tl
|
|
|
|
|
outline.AddArc(0, 0, wid, wid, 180, 90);
|
|
|
|
|
// top line
|
|
|
|
|
outline.AddLine(wid, 0, this.Width - widright, 0);
|
|
|
|
|
// tr
|
|
|
|
|
outline.AddArc(this.Width - widright, 0, wid, wid, 270, 90);
|
|
|
|
|
// br
|
|
|
|
|
outline.AddArc(this.Width - widright, this.Height - widright, wid, wid, 0, 90);
|
|
|
|
|
// bottom line
|
|
|
|
|
outline.AddLine(wid, this.Height - 1, this.Width - widright, this.Height - 1);
|
|
|
|
|
// bl
|
|
|
|
|
outline.AddArc(0, this.Height - widright, wid, wid, 90, 90);
|
2011-12-17 05:22:40 -04:00
|
|
|
|
|
|
|
|
|
|
2012-02-20 07:30:47 -04:00
|
|
|
|
gr.FillPath(linear, outline);
|
|
|
|
|
|
|
|
|
|
gr.DrawPath(mypen, outline);
|
|
|
|
|
|
|
|
|
|
*/
|
2011-12-17 05:22:40 -04:00
|
|
|
|
|
2012-02-20 07:30:47 -04:00
|
|
|
|
gr.FillRectangle(linear, outside);
|
|
|
|
|
gr.DrawRectangle(mypen, outside);
|
2011-12-17 05:22:40 -04:00
|
|
|
|
|
|
|
|
|
|
2012-03-09 11:18:12 -04:00
|
|
|
|
SolidBrush mybrush = new SolidBrush(TextColor);
|
2011-12-17 05:22:40 -04:00
|
|
|
|
|
2012-02-20 07:30:47 -04:00
|
|
|
|
if (mouseover)
|
|
|
|
|
{
|
|
|
|
|
SolidBrush brush = new SolidBrush(Color.FromArgb(73, 0x2b, 0x3a, 0x03));
|
2011-12-17 05:22:40 -04:00
|
|
|
|
|
2012-02-20 07:30:47 -04:00
|
|
|
|
gr.FillRectangle(brush, 0, 0, this.Width, this.Height);
|
|
|
|
|
}
|
|
|
|
|
if (mousedown)
|
|
|
|
|
{
|
|
|
|
|
SolidBrush brush = new SolidBrush(Color.FromArgb(73, 0x2b, 0x3a, 0x03));
|
|
|
|
|
|
|
|
|
|
gr.FillRectangle(brush, 0, 0, this.Width, this.Height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!this.Enabled)
|
|
|
|
|
{
|
|
|
|
|
SolidBrush brush = new SolidBrush(Color.FromArgb(150, 0x2b, 0x3a, 0x03));
|
|
|
|
|
|
|
|
|
|
gr.FillRectangle(brush, 0, 0, this.Width, this.Height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StringFormat stringFormat = new StringFormat();
|
|
|
|
|
stringFormat.Alignment = StringAlignment.Center;
|
|
|
|
|
stringFormat.LineAlignment = StringAlignment.Center;
|
|
|
|
|
|
|
|
|
|
string display = this.Text;
|
|
|
|
|
int amppos = display.IndexOf('&');
|
|
|
|
|
if (amppos != -1)
|
|
|
|
|
display = display.Remove(amppos, 1);
|
|
|
|
|
|
|
|
|
|
gr.DrawString(display, this.Font, mybrush, outside, stringFormat);
|
|
|
|
|
}
|
|
|
|
|
catch { }
|
|
|
|
|
|
|
|
|
|
inOnPaint = false;
|
2011-12-17 05:22:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnClick(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnClick(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnPaintBackground(PaintEventArgs pevent)
|
|
|
|
|
{
|
|
|
|
|
//base.OnPaintBackground(pevent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnMouseEnter(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
mouseover = true;
|
|
|
|
|
base.OnMouseEnter(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnMouseLeave(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
mouseover = false;
|
|
|
|
|
base.OnMouseLeave(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnMouseDown(MouseEventArgs mevent)
|
|
|
|
|
{
|
|
|
|
|
mousedown = true;
|
|
|
|
|
base.OnMouseDown(mevent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnMouseUp(MouseEventArgs mevent)
|
|
|
|
|
{
|
|
|
|
|
mousedown = false;
|
|
|
|
|
base.OnMouseUp(mevent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|