You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
125 lines
3.3 KiB
125 lines
3.3 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Drawing.Drawing2D;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace BiskLog_Point_Of_Sale.Classes
|
|
{
|
|
[DefaultEvent("Click")]
|
|
public partial class MagicButton : UserControl
|
|
{
|
|
string text;
|
|
Image image;
|
|
int wh = 20;
|
|
float angle = 45;
|
|
Color top = Color.DarkGreen;
|
|
Color bottom = Color.DarkKhaki;
|
|
Color textColor = Color.White;
|
|
Timer t = new Timer();
|
|
public int BorderRadius { get { return wh; } set { wh = value; Invalidate(); } }
|
|
public Color ColorTop
|
|
{
|
|
get
|
|
{
|
|
return top;
|
|
}
|
|
set
|
|
{
|
|
top = value; Invalidate();
|
|
}
|
|
}
|
|
public Color ColorBottom
|
|
{
|
|
get { return bottom; }
|
|
set
|
|
{
|
|
bottom = value;
|
|
Invalidate();
|
|
}
|
|
}
|
|
public Image ButtonImage
|
|
{
|
|
get
|
|
{
|
|
return image;
|
|
}
|
|
set
|
|
{
|
|
image = value;
|
|
Invalidate();
|
|
}
|
|
}
|
|
public string ButtonText
|
|
{
|
|
get
|
|
{
|
|
return text;
|
|
}
|
|
set
|
|
{
|
|
text = value;
|
|
Invalidate();
|
|
}
|
|
}
|
|
public Color ForeColor1
|
|
{
|
|
get
|
|
{
|
|
return textColor;
|
|
}
|
|
set
|
|
{
|
|
textColor = value;
|
|
Invalidate();
|
|
}
|
|
}
|
|
public float Angle
|
|
{
|
|
get
|
|
{
|
|
return angle;
|
|
}
|
|
set
|
|
{
|
|
angle = value;
|
|
Invalidate();
|
|
}
|
|
}
|
|
public MagicButton()
|
|
{
|
|
DoubleBuffered = true;
|
|
t.Interval = 50;
|
|
t.Start();
|
|
t.Tick += (s, e) => { Angle = Angle % 360 + 1; };
|
|
}
|
|
protected override void OnPaint(PaintEventArgs e)
|
|
{
|
|
Graphics graphics = e.Graphics;
|
|
graphics.SmoothingMode = SmoothingMode.HighQuality;
|
|
graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault;
|
|
GraphicsPath graphicsPath = new GraphicsPath();
|
|
graphicsPath.AddArc(new Rectangle(0, 0, wh, wh), 180, 90);
|
|
graphicsPath.AddArc(new Rectangle(Width - wh, 0, wh, wh), -90, 90);
|
|
graphicsPath.AddArc(new Rectangle(Width - wh, Height - wh, wh, wh), 0, 90);
|
|
graphicsPath.AddArc(new Rectangle(0, Height - wh, wh, wh), 90, 90);
|
|
e.Graphics.FillPath(new LinearGradientBrush(ClientRectangle, top, bottom, angle), graphicsPath);
|
|
base.OnPaint(e);
|
|
|
|
if (image != null)
|
|
{
|
|
graphics.DrawImage(image, 10, 5, 24, 24);
|
|
}
|
|
|
|
StringFormat sf = new StringFormat();
|
|
sf.Alignment = StringAlignment.Center;
|
|
sf.LineAlignment = StringAlignment.Center;
|
|
|
|
graphics.DrawString(ButtonText, Font, new SolidBrush(ForeColor), ClientRectangle, sf);
|
|
}
|
|
}
|
|
}
|
|
|