58 lines
1.3 KiB
C#
58 lines
1.3 KiB
C#
using System;
|
|
using System.Drawing;
|
|
using System.Drawing.Drawing2D;
|
|
using System.Windows.Forms;
|
|
|
|
internal class PField : Panel
|
|
{
|
|
public TextBox Box;
|
|
|
|
private bool foc;
|
|
|
|
public PField()
|
|
{
|
|
SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, value: true);
|
|
BackColor = G.Card;
|
|
Box = new TextBox();
|
|
Box.BorderStyle = BorderStyle.None;
|
|
Box.BackColor = G.Bg;
|
|
Box.ForeColor = G.Txt;
|
|
Box.Font = G.N;
|
|
Box.TextAlign = HorizontalAlignment.Center;
|
|
Box.UseSystemPasswordChar = true;
|
|
TextBox box = Box;
|
|
EventHandler value = (object param0, EventArgs param1) =>
|
|
{
|
|
foc = true;
|
|
Invalidate();
|
|
};
|
|
box.GotFocus += value;
|
|
Box.LostFocus += (object param0, EventArgs param1) =>
|
|
{
|
|
foc = false;
|
|
Invalidate();
|
|
};
|
|
Controls.Add(Box);
|
|
}
|
|
|
|
protected override void OnResize(EventArgs e)
|
|
{
|
|
base.OnResize(e);
|
|
if (Box != null)
|
|
{
|
|
Box.SetBounds(16, (Height - 22) / 2, Width - 32, 22);
|
|
}
|
|
}
|
|
|
|
protected override void OnPaint(PaintEventArgs e)
|
|
{
|
|
Graphics graphics = e.Graphics;
|
|
graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
|
graphics.Clear(G.Card);
|
|
RectangleF r = new RectangleF(0f, 0f, Width - 1, Height - 1);
|
|
G.Fill(graphics, r, 12f, G.Bg);
|
|
using Pen pen = new Pen(foc ? G.Acc : G.Line, 1.4f);
|
|
graphics.DrawPath(pen, G.RR(r, 12f));
|
|
}
|
|
}
|