diff options
Diffstat (limited to 'Histacom2.Engine/UI')
| -rw-r--r-- | Histacom2.Engine/UI/ClassicDropDown.Designer.cs | 30 | ||||
| -rw-r--r-- | Histacom2.Engine/UI/ClassicDropDown.cs | 82 | ||||
| -rw-r--r-- | Histacom2.Engine/UI/ClassicTextbox.cs | 12 | ||||
| -rw-r--r-- | Histacom2.Engine/UI/OldClassicTextbox.cs | 77 |
4 files changed, 104 insertions, 97 deletions
diff --git a/Histacom2.Engine/UI/ClassicDropDown.Designer.cs b/Histacom2.Engine/UI/ClassicDropDown.Designer.cs index da54d6e..509c04d 100644 --- a/Histacom2.Engine/UI/ClassicDropDown.Designer.cs +++ b/Histacom2.Engine/UI/ClassicDropDown.Designer.cs @@ -29,12 +29,12 @@ private void InitializeComponent() { this.textBox1 = new System.Windows.Forms.TextBox(); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.dropDownSwitch = new System.Windows.Forms.PictureBox(); this.tborder = new System.Windows.Forms.PictureBox(); this.bborder = new System.Windows.Forms.PictureBox(); this.rborder = new System.Windows.Forms.PictureBox(); this.lborder = new System.Windows.Forms.PictureBox(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.dropDownSwitch)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tborder)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.bborder)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.rborder)).BeginInit(); @@ -50,16 +50,17 @@ this.textBox1.Size = new System.Drawing.Size(96, 13); this.textBox1.TabIndex = 9; // - // pictureBox1 + // dropDownSwitch // - this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Right; - this.pictureBox1.Image = global::Histacom2.Engine.Properties.Resources.ClassicDropDownButton; - this.pictureBox1.Location = new System.Drawing.Point(82, 2); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(16, 16); - this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; - this.pictureBox1.TabIndex = 10; - this.pictureBox1.TabStop = false; + this.dropDownSwitch.Dock = System.Windows.Forms.DockStyle.Right; + this.dropDownSwitch.Image = global::Histacom2.Engine.Properties.Resources.ClassicDropDownButton; + this.dropDownSwitch.Location = new System.Drawing.Point(82, 2); + this.dropDownSwitch.Name = "dropDownSwitch"; + this.dropDownSwitch.Size = new System.Drawing.Size(16, 16); + this.dropDownSwitch.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; + this.dropDownSwitch.TabIndex = 10; + this.dropDownSwitch.TabStop = false; + this.dropDownSwitch.Click += new System.EventHandler(this.dropDownSwitch_Click); // // tborder // @@ -101,7 +102,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.pictureBox1); + this.Controls.Add(this.dropDownSwitch); this.Controls.Add(this.textBox1); this.Controls.Add(this.tborder); this.Controls.Add(this.bborder); @@ -109,7 +110,8 @@ this.Controls.Add(this.lborder); this.Name = "ClassicDropDown"; this.Size = new System.Drawing.Size(100, 20); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.Load += new System.EventHandler(this.ClassicDropDown_Load); + ((System.ComponentModel.ISupportInitialize)(this.dropDownSwitch)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.tborder)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.bborder)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.rborder)).EndInit(); @@ -126,6 +128,6 @@ private System.Windows.Forms.PictureBox bborder; private System.Windows.Forms.PictureBox rborder; private System.Windows.Forms.PictureBox lborder; - private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.PictureBox dropDownSwitch; } } diff --git a/Histacom2.Engine/UI/ClassicDropDown.cs b/Histacom2.Engine/UI/ClassicDropDown.cs index b26862e..0b56cb9 100644 --- a/Histacom2.Engine/UI/ClassicDropDown.cs +++ b/Histacom2.Engine/UI/ClassicDropDown.cs @@ -7,22 +7,28 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using Histacom2.Engine.Template; namespace Histacom2.Engine.UI { public partial class ClassicDropDown : UserControl { + public DropDownOverlay thisOverlay = new DropDownOverlay(); public bool UseSystemPasswordChar { get; set; } + public bool dropDownShown; public static Color textboxcolor = Color.Black; public static Color _lightBack = Color.Silver; public static Color _darkBack = Color.Silver; + public List<string> items = new List<string> { "TestItem" }; + public ClassicDropDown() { InitializeComponent(); + try { // Draw the border @@ -30,20 +36,26 @@ namespace Histacom2.Engine.UI 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; - else textBox1.BackColor = Color.White; + textBox1.Font = Font; if (SaveSystem.currentTheme != null) { + textBox1.BackColor = SaveSystem.currentTheme.threeDObjectsColor; + BackColor = SaveSystem.currentTheme.threeDObjectsColor; + textboxcolor = SaveSystem.currentTheme.windowColor; _lightBack = Paintbrush.GetLightFromColor(textboxcolor); _darkBack = Paintbrush.GetDarkFromColor(textboxcolor); } + else + { + textBox1.BackColor = Color.White; + BackColor = Color.White; + } }); + tborder.Paint += new PaintEventHandler((object sender, PaintEventArgs e) => { @@ -77,5 +89,67 @@ namespace Histacom2.Engine.UI } catch { } } + + public void ChooseItem(string str) + { + textBox1.Text = str; + ShowHideDropDown(); + } + + public void ShowHideDropDown() + { + if (dropDownShown) + { + thisOverlay.Close(); + dropDownShown = false; + } else { + thisOverlay = new DropDownOverlay(); + int applyHeight = 0; + foreach (string str in items) + { + DropDownItem itm = new DropDownItem(); + itm.ChangeText(str, Font); + itm.dpdw = this; + itm.Dock = DockStyle.Top; + applyHeight += itm.Height; + thisOverlay.outline.Controls.Add(itm); + } + thisOverlay.outline.Location = this.PointToScreen(Point.Empty); + thisOverlay.outline.Top += this.Height; + thisOverlay.outline.Size = new Size(this.Width, applyHeight); + + thisOverlay.Deactivate += (sender2, e2) => { thisOverlay.Close(); dropDownShown = false; }; + + thisOverlay.Show(); + dropDownShown = true; + } + } + + private void dropDownSwitch_Click(object sender, EventArgs e) + { + ShowHideDropDown(); + } + + private void ClassicDropDown_Load(object sender, EventArgs e) + { + try + { + ((Form)this.TopLevelControl).FormClosed += (sender2, e2) => { thisOverlay.Close(); }; + ((Form)this.TopLevelControl).Resize += (sender2, e2) => + { + thisOverlay.outline.Location = this.PointToScreen(Point.Empty); + thisOverlay.outline.Top += this.Height; + thisOverlay.BringToFront(); + }; + + ((Form)this.TopLevelControl).Move += (sender2, e2) => + { + thisOverlay.outline.Location = this.PointToScreen(Point.Empty); + thisOverlay.outline.Top += this.Height; + thisOverlay.BringToFront(); + }; + } catch { } + + } } } diff --git a/Histacom2.Engine/UI/ClassicTextbox.cs b/Histacom2.Engine/UI/ClassicTextbox.cs index a42c2b1..8f1f9c3 100644 --- a/Histacom2.Engine/UI/ClassicTextbox.cs +++ b/Histacom2.Engine/UI/ClassicTextbox.cs @@ -32,8 +32,16 @@ namespace Histacom2.Engine.UI // 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; - else textBox1.BackColor = Color.White; + 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) { diff --git a/Histacom2.Engine/UI/OldClassicTextbox.cs b/Histacom2.Engine/UI/OldClassicTextbox.cs deleted file mode 100644 index f7db87d..0000000 --- a/Histacom2.Engine/UI/OldClassicTextbox.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace Histacom2.Engine.UI -{ - //public class OldClassicTextbox : Control - //{ - // private System.ComponentModel.IContainer components = null; - // public TextBox tb = new TextBox(); - // public bool UseSystemPasswordChar { get; set; } - - // public ClassicTextbox() : base() - // { - // // A bunch of designer stuff! - // this.components = new System.ComponentModel.Container(); - // this.SuspendLayout(); - - // if (SaveSystem.currentTheme != null) Font = SaveSystem.currentTheme.buttonFont; - // else Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular); - - // tb.Name = "mainText"; - // tb.Location = new Point(3, 3); - // tb.Size = new Size(Size.Width - 6, Size.Height - 6); - // tb.BorderStyle = BorderStyle.None; - // Controls.Add(tb); - - // this.ResumeLayout(false); - // } - - // protected override void Dispose(bool disposing) - // { - // if (disposing && (components != null)) - // { - // components.Dispose(); - // } - // base.Dispose(disposing); - // } - - // protected override void OnPaint(PaintEventArgs e) - // { - - // var textboxcolor = Color.Silver; - // if (SaveSystem.currentTheme != null) textboxcolor = SaveSystem.currentTheme.windowColor; - - // if (SaveSystem.currentTheme != null) BackColor = SaveSystem.currentTheme.threeDObjectsColor; - // else BackColor = Color.White; - - // 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); - - // var g = e.Graphics; - // g.Clear(BackColor); - - // 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); - - // 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); - - // base.OnPaint(e); - // } -} |
