private void DrawTriangle(Graphics g, Brush br, Rectangle area, MyButtonType direction) { Point[] trian_pts = new Point[3]; trian_pts[0].X = area.Left; trian_pts[0].Y = area.Bottom; trian_pts[1].X = area.Right; trian_pts[1].Y = area.Top; trian_pts[2].X = area.Right; trian_pts[2].Y = area.Bottom; if (direction == MyButtonType.trianglelfButton) { trian_pts[0].Y = area.Top + area.Height / 2; } else if (direction == MyButtonType.triangleupButton) { trian_pts[1].X = area.Left + area.Width / 2; } else if (direction == MyButtonType.trianglertButton) { trian_pts[1].X = area.Left; trian_pts[2].Y = area.Top + area.Height / 2; } else if (direction == MyButtonType.trianglednButton) { trian_pts[0].Y = area.Top; trian_pts[2].X = area.Left + area.Width / 2; } g.FillPolygon(br, trian_pts); }
public RectButton() { InitializeComponent(); this.MouseUp += new MouseEventHandler(RectButton_Click); btnType = MyButtonType.invalid; this.colorTop = Color.LightGreen; this.colorBottom = Color.Gray; }
public void SetStyle(Color tcolor, MyButtonType type) { int bgScale = 3; int bdScale = 4; /* Color tcolor = Color.Red; * if (style.IndexOf("LightGreen_") == 0) * tcolor = Color.LightGreen; * if (style.IndexOf("DarkGreen_") == 0) * tcolor = Color.DarkGreen; * if (style.IndexOf("Goldenrod_") == 0) * tcolor = Color.Goldenrod; * if (style.IndexOf("Gray_") == 0) * tcolor = Color.Goldenrod; */ btnType = type; if (type == MyButtonType.roundRectButton || type == MyButtonType.roundGradientButton) { colorTop = tcolor; areaTop = new Rectangle(0, 0, this.ClientSize.Width - bgScale, this.ClientSize.Height - bgScale); colorBottom = Color.Gray; areaBottom = new Rectangle(bgScale, bgScale, this.ClientSize.Width - bgScale, this.ClientSize.Height - bgScale); } if (type == MyButtonType.round2RectButton || type == MyButtonType.roundRect) { colorTop = tcolor; areaTop = new Rectangle(bdScale, bdScale, this.ClientSize.Width - 2 * bdScale, this.ClientSize.Height - 2 * bdScale); colorBottom = Color.Black; areaBottom = this.ClientRectangle; } if (type == MyButtonType.roundButton) { colorTop = tcolor; int iBorder = this.ClientSize.Width; if (iBorder > this.ClientSize.Height) { iBorder = this.ClientSize.Height; } areaTop = new Rectangle(0, 0, iBorder - bgScale, iBorder - bgScale); colorBottom = Color.Gray; areaBottom = new Rectangle(bgScale, bgScale, iBorder - bgScale, iBorder - bgScale); } if (type == MyButtonType.round2Button) { colorTop = tcolor; int iBorder = this.ClientSize.Width; if (iBorder > this.ClientSize.Height) { iBorder = this.ClientSize.Height; } areaTop = new Rectangle(bdScale, bdScale, iBorder - 2 * bdScale, iBorder - 2 * bdScale); colorBottom = Color.Black; areaBottom = new Rectangle(0, 0, iBorder, iBorder); } areaTop.Inflate(-1, -1); areaBottom.Inflate(-1, -1); this.Invalidate(); }
public RectButton() { InitializeComponent(); timeout = new Timer(); timeout.Tick += new EventHandler(timeout_Tick); timeout.Interval = 200; this.MouseDown += new MouseEventHandler(RectButton_MouseDown); this.MouseUp += new MouseEventHandler(RectButton_Click); btnType = MyButtonType.invalid; this.colorTop = Color.LightGreen; this.colorBottom = Color.Gray; timeout.Enabled = true ; }
public RectButton() { InitializeComponent(); timeout = new Timer(); timeout.Tick += new EventHandler(timeout_Tick); timeout.Interval = 200; this.MouseDown += new MouseEventHandler(RectButton_MouseDown); this.MouseUp += new MouseEventHandler(RectButton_Click); btnType = MyButtonType.invalid; this.colorTop = Color.LightGreen; this.colorBottom = Color.Gray; timeout.Start(); }
public MyToolButton(MyButtonType btnType) { buttonType = btnType; if (buttonType == MyButtonType.Link) { width = 60; height = 13; } else { width = height = 10; } viewInfo = CreateViewInfo(); painter = CreatePainter(); }
public void SetStyle(Color tcolor, MyButtonType type) { int bgScale = 3; int bdScale = 3; if (btnType == MyButtonType.invalid) { backBuffer = new Bitmap(this.Width, this.Height); graphic = Graphics.FromImage(backBuffer); } /* Color tcolor = Color.Red; if (style.IndexOf("LightGreen_") == 0) tcolor = Color.LightGreen; if (style.IndexOf("DarkGreen_") == 0) tcolor = Color.DarkGreen; if (style.IndexOf("Goldenrod_") == 0) tcolor = Color.Goldenrod; if (style.IndexOf("Gray_") == 0) tcolor = Color.Goldenrod; */ btnType = type; if (btnType == MyButtonType.trianglednButton || btnType == MyButtonType.trianglelfButton || btnType == MyButtonType.trianglertButton || btnType == MyButtonType.triangleupButton) { colorTop = tcolor; areaTop = new Rectangle(0, 0, this.ClientSize.Width - bgScale, this.ClientSize.Height - bgScale); colorBottom = Color.Gray; areaBottom = new Rectangle(bgScale, bgScale, this.ClientSize.Width - bgScale, this.ClientSize.Height - bgScale); } if (type == MyButtonType.roundRectButton || type == MyButtonType.roundGradientButton) { colorTop = tcolor; areaTop = new Rectangle(0, 0, this.ClientSize.Width - bgScale, this.ClientSize.Height - bgScale); colorBottom = Color.Gray; areaBottom = new Rectangle(bgScale, bgScale, this.ClientSize.Width - bgScale, this.ClientSize.Height - bgScale); } if (type == MyButtonType.round2RectButton || type == MyButtonType.roundRect) { colorTop = tcolor; areaTop = new Rectangle(bdScale, bdScale, this.ClientSize.Width - 2 * bdScale, this.ClientSize.Height - 2 * bdScale); colorBottom = bgColor; areaBottom = this.ClientRectangle; } if (type == MyButtonType.roundButton) { colorTop = tcolor; int iBorder = this.ClientSize.Width; if (iBorder > this.ClientSize.Height) iBorder = this.ClientSize.Height; areaTop = new Rectangle(0, 0, iBorder - bgScale, iBorder - bgScale); colorBottom = Color.Gray; areaBottom = new Rectangle(bgScale, bgScale, iBorder - bgScale, iBorder - bgScale); } if (type == MyButtonType.round2Button) { colorTop = tcolor; int iBorder = this.ClientSize.Width; if (iBorder > this.ClientSize.Height) iBorder = this.ClientSize.Height; areaTop = new Rectangle(bdScale, bdScale, iBorder - 2 * bdScale, iBorder - 2 * bdScale); colorBottom = bgColor; areaBottom = new Rectangle(0, 0, iBorder, iBorder); } areaTop.Inflate(-1, -1); areaBottom.Inflate(-1, -1); this.Invalidate(); }
public void SetStyle(Color tcolor, MyButtonType type) { int bgScale = 3; int bdScale = 3; if (btnType == MyButtonType.invalid) { backBuffer = new Bitmap(this.Width, this.Height); graphic = Graphics.FromImage(backBuffer); } /* Color tcolor = Color.Red; * if (style.IndexOf("LightGreen_") == 0) * tcolor = Color.LightGreen; * if (style.IndexOf("DarkGreen_") == 0) * tcolor = Color.DarkGreen; * if (style.IndexOf("Goldenrod_") == 0) * tcolor = Color.Goldenrod; * if (style.IndexOf("Gray_") == 0) * tcolor = Color.Goldenrod; */ btnType = type; if (btnType == MyButtonType.trianglednButton || btnType == MyButtonType.trianglelfButton || btnType == MyButtonType.trianglertButton || btnType == MyButtonType.triangleupButton) { colorTop = tcolor; areaTop = new Rectangle(0, 0, this.ClientSize.Width - bgScale, this.ClientSize.Height - bgScale); colorBottom = Color.Gray; areaBottom = new Rectangle(bgScale, bgScale, this.ClientSize.Width - bgScale, this.ClientSize.Height - bgScale); } if (type == MyButtonType.roundRectButton || type == MyButtonType.roundGradientButton) { colorTop = tcolor; areaTop = new Rectangle(0, 0, this.ClientSize.Width - bgScale, this.ClientSize.Height - bgScale); colorBottom = Color.Gray; areaBottom = new Rectangle(bgScale, bgScale, this.ClientSize.Width - bgScale, this.ClientSize.Height - bgScale); } if (type == MyButtonType.round2RectButton || type == MyButtonType.roundRect) { colorTop = tcolor; areaTop = new Rectangle(bdScale, bdScale, this.ClientSize.Width - 2 * bdScale, this.ClientSize.Height - 2 * bdScale); colorBottom = bgColor; areaBottom = this.ClientRectangle; } if (type == MyButtonType.roundButton) { colorTop = tcolor; int iBorder = this.ClientSize.Width; if (iBorder > this.ClientSize.Height) { iBorder = this.ClientSize.Height; } areaTop = new Rectangle(0, 0, iBorder - bgScale, iBorder - bgScale); colorBottom = Color.Gray; areaBottom = new Rectangle(bgScale, bgScale, iBorder - bgScale, iBorder - bgScale); } if (type == MyButtonType.round2Button) { colorTop = tcolor; int iBorder = this.ClientSize.Width; if (iBorder > this.ClientSize.Height) { iBorder = this.ClientSize.Height; } areaTop = new Rectangle(bdScale, bdScale, iBorder - 2 * bdScale, iBorder - 2 * bdScale); colorBottom = bgColor; areaBottom = new Rectangle(0, 0, iBorder, iBorder); } areaTop.Inflate(-1, -1); areaBottom.Inflate(-1, -1); this.Invalidate(); }
public void SetStyle(Color tcolor, MyButtonType type) { int bgScale = 3; int bdScale = 4; /* Color tcolor = Color.Red; if (style.IndexOf("LightGreen_") == 0) tcolor = Color.LightGreen; if (style.IndexOf("DarkGreen_") == 0) tcolor = Color.DarkGreen; if (style.IndexOf("Goldenrod_") == 0) tcolor = Color.Goldenrod; if (style.IndexOf("Gray_") == 0) tcolor = Color.Goldenrod; */ btnType = type; if (type == MyButtonType.roundRectButton || type == MyButtonType.roundGradientButton) { colorTop = tcolor; areaTop = new Rectangle(0, 0, this.ClientSize.Width - bgScale, this.ClientSize.Height - bgScale); colorBottom = Color.Gray; areaBottom = new Rectangle(bgScale, bgScale, this.ClientSize.Width - bgScale, this.ClientSize.Height - bgScale); } if (type == MyButtonType.round2RectButton || type == MyButtonType.roundRect) { colorTop = tcolor; areaTop = new Rectangle(bdScale, bdScale, this.ClientSize.Width - 2*bdScale, this.ClientSize.Height - 2*bdScale); colorBottom = Color.Black; areaBottom = this.ClientRectangle; } if (type == MyButtonType.roundButton) { colorTop = tcolor; int iBorder = this.ClientSize.Width; if (iBorder > this.ClientSize.Height) iBorder = this.ClientSize.Height; areaTop = new Rectangle(0, 0, iBorder - bgScale, iBorder - bgScale); colorBottom = Color.Gray; areaBottom = new Rectangle(bgScale, bgScale, iBorder - bgScale, iBorder - bgScale); } if (type == MyButtonType.round2Button) { colorTop = tcolor; int iBorder = this.ClientSize.Width; if (iBorder > this.ClientSize.Height) iBorder = this.ClientSize.Height; areaTop = new Rectangle(bdScale, bdScale, iBorder - 2 * bdScale, iBorder - 2 * bdScale); colorBottom = Color.Black; areaBottom = new Rectangle(0, 0, iBorder, iBorder); } areaTop.Inflate(-1, -1); areaBottom.Inflate(-1, -1); this.Invalidate(); }