using System; using System.Drawing; using System.Windows.Forms; namespace VictusLauncher { public class DuskTextBox : Panel { public readonly TextBox TextBox; protected readonly Panel OverlayPanel1; protected readonly Panel OverlayPanel2; public new String Text { get { return TextBox.Text; } set { TextBox.Text = value; } } public Char PasswordChar { get { return TextBox.PasswordChar; } set { TextBox.PasswordChar = value; } } public DuskTextBox() { TextBox = new TextBox { Location = new Point(2, 1), BorderStyle = BorderStyle.None }; TextBox.GotFocus += OnTextBoxGotFocus; TextBox.LostFocus += OnTextBoxLostFocus; OverlayPanel1 = new Panel { BackColor = Color.Transparent }; OverlayPanel2 = new Panel { BackColor = Color.Transparent }; Controls.Add(OverlayPanel1); Controls.Add(OverlayPanel2); Controls.Add(TextBox); } protected override void OnCreateControl() { TextBox.Size = Size - new Size(4, 0); OverlayPanel1.Size = new Size(5, 5); OverlayPanel1.Location = new Point(0, 0); OverlayPanel2.Size = new Size(5, 5); OverlayPanel2.Location = new Point(Width-5, 0); base.OnCreateControl(); } protected override void OnGotFocus(EventArgs e) { TextBox.Focus(); base.OnGotFocus(e); } public void OnTextBoxGotFocus(object sender, EventArgs e) { Refresh(); } public void OnTextBoxLostFocus(object sender, EventArgs e) { Refresh(); } protected override void OnPaint(PaintEventArgs args) { Graphics o1Graphics = OverlayPanel1.CreateGraphics(); Graphics o2Graphics = OverlayPanel2.CreateGraphics(); SolidBrush bBrush = new SolidBrush(TextBox.Focused ? Color.DarkOrange : Color.LightGray); SolidBrush tbBrush = new SolidBrush(Color.White); SolidBrush bgBrush = new SolidBrush(Color.LightGray); Pen bgPen = new Pen(bgBrush, 1.0f); Pen tbPen = new Pen(tbBrush, 1.0f); Pen bPen = new Pen(bBrush, 1.6f); o1Graphics.DrawLine(bgPen, 0, 0, 2, 0); o1Graphics.DrawLine(bgPen, 0, 1, 2, 1); o1Graphics.DrawLine(bgPen, 0, 2, 2, 2); o1Graphics.DrawLine(tbPen, 4, 1, 6, 1); o1Graphics.DrawLine(tbPen, 2, 2, 6, 2); o1Graphics.DrawLine(tbPen, 1, 3, 6, 3); o1Graphics.DrawLine(tbPen, 1, 4, 6, 4); o2Graphics.DrawLine(bgPen, 2, 0, 4, 0); o2Graphics.DrawLine(bgPen, 3, 1, 3, 1); o2Graphics.DrawLine(bgPen, 4, 1, 4, 3); o2Graphics.DrawLine(tbPen, 0, 1, 2, 1); o2Graphics.DrawLine(tbPen, 0, 2, 2, 2); o2Graphics.DrawLine(tbPen, 0, 3, 2, 3); o2Graphics.DrawLine(tbPen, 0, 4, 3, 4); args.Graphics.DrawLine(bPen, 0, Height - 1, Width, Height - 1); args.Graphics.DrawLine(bPen, 0, Height - 1, 0, 4); args.Graphics.DrawLine(bPen, Width - 1, Height - 1, Width - 1, 4); args.Graphics.DrawLine(bPen, 4, 0, Width - 4, 0); Point[] lTopCurve = new[] { new Point(0, 4), new Point(1, 2), new Point(2, 1), new Point(4, 0), }; Point[] rTopCurve = new[] { new Point(4, 4), new Point(2, 1), new Point(0, 0), }; o1Graphics.DrawCurve(bPen, lTopCurve); o2Graphics.DrawCurve(bPen, rTopCurve); base.OnPaint(args); } } }