diff options
| author | Alex-TIMEHACK <[email protected]> | 2017-10-24 11:18:12 +0100 |
|---|---|---|
| committer | Alex-TIMEHACK <[email protected]> | 2017-10-24 11:18:12 +0100 |
| commit | e5f29e7b53322e11578acd0deb3b1d454998bb77 (patch) | |
| tree | 7cca33ae9ec7e8ea09fdd20a23a69a52d734d1c4 /Histacom2.Engine/UI/ClassicTextbox.cs | |
| parent | 350e749bb9eab16efe753f9b8fd703b52a97f808 (diff) | |
| download | histacom2-e5f29e7b53322e11578acd0deb3b1d454998bb77.tar.gz histacom2-e5f29e7b53322e11578acd0deb3b1d454998bb77.tar.bz2 histacom2-e5f29e7b53322e11578acd0deb3b1d454998bb77.zip | |
All new ClassicTextBox
Diffstat (limited to 'Histacom2.Engine/UI/ClassicTextbox.cs')
| -rw-r--r-- | Histacom2.Engine/UI/ClassicTextbox.cs | 85 |
1 files changed, 56 insertions, 29 deletions
diff --git a/Histacom2.Engine/UI/ClassicTextbox.cs b/Histacom2.Engine/UI/ClassicTextbox.cs index e38af16..8c1d8d8 100644 --- a/Histacom2.Engine/UI/ClassicTextbox.cs +++ b/Histacom2.Engine/UI/ClassicTextbox.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Drawing; +using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -8,47 +10,72 @@ using System.Windows.Forms; namespace Histacom2.Engine.UI { - public class ClassicTextbox : Control + public partial class ClassicTextBox : UserControl { public bool UseSystemPasswordChar { get; set; } - public ClassicTextbox() : base() - { - if (SaveSystem.currentTheme != null) Font = SaveSystem.currentTheme.buttonFont; - else Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular); - } + public static Color textboxcolor = Color.Black; - protected override void OnPaint(PaintEventArgs e) + public static Color _lightBack = Color.Silver; + public static Color _darkBack = Color.Silver; + + public ClassicTextBox() { - base.OnPaint(e); + InitializeComponent(); + + try + { + // Draw the border + + this.Paint += new PaintEventHandler((object sender, PaintEventArgs e) => + { + // Update a bunch of variables! + if (SaveSystem.currentTheme != null) textBox1.Font = SaveSystem.currentTheme.buttonFont; + else textBox1.Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular); + + if (SaveSystem.currentTheme != null) BackColor = SaveSystem.currentTheme.threeDObjectsColor; + else BackColor = Color.White; + + if (SaveSystem.currentTheme != null) + { + textboxcolor = SaveSystem.currentTheme.windowColor; + + _lightBack = Paintbrush.GetLightFromColor(textboxcolor); + _darkBack = Paintbrush.GetDarkFromColor(textboxcolor); + } + }); - var textboxcolor = Color.Silver; - if (SaveSystem.currentTheme != null) textboxcolor = SaveSystem.currentTheme.windowColor; - if (SaveSystem.currentTheme != null) BackColor = SaveSystem.currentTheme.threeDObjectsColor; - else BackColor = Color.White; + tborder.Paint += new PaintEventHandler((object sender, PaintEventArgs e) => + { + e.Graphics.DrawLine(new Pen(_darkBack), 0, 0, tborder.Width, 0); + e.Graphics.DrawLine(Pens.Black, 0, 1, tborder.Width, 1); - var _lightBack = Paintbrush.GetLightFromColor(textboxcolor); - var _darkBack = Paintbrush.GetDarkFromColor(textboxcolor); + }); - if (SaveSystem.currentTheme != null) Font = SaveSystem.currentTheme.buttonFont; - else Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular); + lborder.Paint += new PaintEventHandler((object sender, PaintEventArgs e) => + { + e.Graphics.DrawLine(new Pen(_darkBack), 0, 0, 0, Height); + e.Graphics.DrawLine(Pens.Black, 1, 0, 1, Height); + }); - var g = e.Graphics; - g.Clear(BackColor); + rborder.Paint += new PaintEventHandler((object sender, PaintEventArgs e) => + { + e.Graphics.DrawLine(new Pen(_lightBack), 0, 0, 0, Height - 1); + e.Graphics.DrawLine(new Pen(textboxcolor), 1, 0, 1, Height - 1); + }); - g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; - if (UseSystemPasswordChar) g.DrawString(new string('●', Text.Length), Font, Brushes.Black, 3, 3); - else g.DrawString(Text, Font, Brushes.Black, 3, 3); + bborder.Paint += new PaintEventHandler((object sender, PaintEventArgs e) => + { + e.Graphics.DrawLine(new Pen(_lightBack), 0, 0, Width - 1, 0); + e.Graphics.DrawLine(new Pen(textboxcolor), 0, 1, Width - 2, 1); + }); - g.DrawLine(new Pen(_darkBack), 0, 0, Width - 2, 0); - g.DrawLine(new Pen(_lightBack), Width - 1, 0, Width - 1, Height - 1); - g.DrawLine(new Pen(_lightBack), 0, Height - 1, Width - 1, Height - 1); - g.DrawLine(new Pen(_darkBack), 0, 0, 0, Height - 2); - g.DrawLine(Pens.Black, 1, 1, Width - 3, 1); - g.DrawLine(Pens.Black, 1, 1, 1, Height - 3); - g.DrawLine(new Pen(textboxcolor), 1, Height - 2, Width - 2, Height - 2); - g.DrawLine(new Pen(textboxcolor), Width - 2, Height - 2, Width - 2, 1); + tborder.Invalidate(); + lborder.Invalidate(); + rborder.Invalidate(); + bborder.Invalidate(); + } catch { } } } } |
