aboutsummaryrefslogtreecommitdiff
path: root/Histacom2.Engine/UI/ClassicTextbox.cs
blob: 8f1f9c3c6ea98f14f1790e7760dcdc5fa7de1edb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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;
using System.Windows.Forms;

namespace Histacom2.Engine.UI
{
    public partial class ClassicTextBox : UserControl
    {
        public bool UseSystemPasswordChar { get; set; }

        public static Color textboxcolor = Color.Black;

        public static Color _lightBack = Color.Silver;
        public static Color _darkBack = Color.Silver;

        public ClassicTextBox()
        {
            InitializeComponent();

            try
            {
                // Draw the border    

                this.Paint += new PaintEventHandler((object sender, PaintEventArgs e) =>
                {
                    // Update a bunch of variables!
                    textBox1.Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular);

                    if (SaveSystem.currentTheme != null)
                    {
                        textBox1.BackColor = SaveSystem.currentTheme.threeDObjectsColor;
                        BackColor = SaveSystem.currentTheme.threeDObjectsColor;
                    }
                    else
                    {
                        textBox1.BackColor = Color.White;
                        BackColor = Color.White;
                    }

                    if (SaveSystem.currentTheme != null)
                    {
                        textboxcolor = SaveSystem.currentTheme.windowColor;

                        _lightBack = Paintbrush.GetLightFromColor(textboxcolor);
                        _darkBack = Paintbrush.GetDarkFromColor(textboxcolor);
                    }
                });


                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);

                });

                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);
                });

                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);
                });

                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);
                });

                tborder.Invalidate();
                lborder.Invalidate();
                rborder.Invalidate();
                bborder.Invalidate();
            } catch { }
        }
    }
}