2020-04-27 12:17:13 +00:00
|
|
|
|
namespace RyzStudio.Windows.ThemedForms
|
|
|
|
|
{
|
|
|
|
|
using RyzStudio.Drawing;
|
|
|
|
|
using System;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
2020-05-10 10:45:54 +00:00
|
|
|
|
public partial class TListBox : RyzStudio.Windows.ThemedForms.TUserControl
|
2020-04-27 12:17:13 +00:00
|
|
|
|
{
|
|
|
|
|
protected readonly Padding textboxPadding = new Padding(6, 2, 4, 2);
|
|
|
|
|
|
2020-05-10 10:45:54 +00:00
|
|
|
|
public TListBox() : base()
|
2020-04-27 12:17:13 +00:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
this.Font = new Font(this.Font, FontStyle.Regular);
|
|
|
|
|
this.Margin = new Padding(10, 4, 10, 4);
|
|
|
|
|
|
|
|
|
|
comboBox1.Font = this.Font;
|
|
|
|
|
comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
|
|
|
comboBox1.PreviewKeyDown += textBox_PreviewKeyDown;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnResize(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnResize(e);
|
|
|
|
|
|
|
|
|
|
int b = (styleActive.BorderWidth + 1) + styleActive.BorderPadding;
|
|
|
|
|
|
|
|
|
|
this.Height = comboBox1.Height + (b + textboxPadding.Top) + ((b - 1) + textboxPadding.Bottom);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnGotFocus(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnGotFocus(e);
|
|
|
|
|
|
|
|
|
|
comboBox1.Focus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void textBox_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
switch (e.KeyCode)
|
|
|
|
|
{
|
|
|
|
|
case Keys.Enter:
|
|
|
|
|
if (this.SubmitButton != null)
|
|
|
|
|
{
|
|
|
|
|
this.SubmitButton.PerformClick();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case Keys.Escape:
|
2020-05-10 10:34:45 +00:00
|
|
|
|
close();
|
2020-04-27 12:17:13 +00:00
|
|
|
|
break;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Browsable(true), EditorBrowsable(EditorBrowsableState.Advanced)]
|
|
|
|
|
[Category("Appearance")]
|
|
|
|
|
public System.Windows.Forms.ComboBox ComboBox { get => comboBox1; set => comboBox1 = value; }
|
|
|
|
|
|
|
|
|
|
//[Browsable(true), EditorBrowsable(EditorBrowsableState.Advanced)]
|
|
|
|
|
//[Category("Appearance")]
|
|
|
|
|
//public new string Text
|
|
|
|
|
//{
|
|
|
|
|
// get => textBox1.Text;
|
|
|
|
|
// set
|
|
|
|
|
// {
|
|
|
|
|
// textBox1.Text = value;
|
|
|
|
|
// textBox1.SelectionStart = textBox1.Text.Length;
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//[Browsable(true)]
|
|
|
|
|
//[Category("Appearance")]
|
|
|
|
|
//public ComboBox.ObjectCollection Items { get => comboBox1.Items; set => comboBox1.Items = value; }
|
|
|
|
|
|
|
|
|
|
[Browsable(true), EditorBrowsable(EditorBrowsableState.Advanced)]
|
|
|
|
|
[Category("Appearance")]
|
2020-05-10 10:45:54 +00:00
|
|
|
|
public TButton SubmitButton { get; set; } = null;
|
2020-04-27 12:17:13 +00:00
|
|
|
|
|
|
|
|
|
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
|
|
|
|
public new Padding Margin { get => base.Margin; set => base.Margin = value; }
|
|
|
|
|
|
2020-05-10 10:34:45 +00:00
|
|
|
|
protected override void updateBackground(Graphics g, Style style)
|
2020-04-27 12:17:13 +00:00
|
|
|
|
{
|
|
|
|
|
int b = (styleActive.BorderWidth + 1) + styleActive.BorderPadding;
|
|
|
|
|
|
|
|
|
|
this.Padding = new Padding((b + textboxPadding.Left), (b + textboxPadding.Top), ((b - 1) + textboxPadding.Right), ((b - 1) + textboxPadding.Bottom));
|
|
|
|
|
|
|
|
|
|
Rectangoid area = new Rectangoid(this.ClientRectangle, style.BorderRadius, style.BorderWidth);
|
|
|
|
|
g.FillPath(new SolidBrush(style.BackColour), area.ToGraphicsPath());
|
|
|
|
|
g.DrawPath(new Pen(new SolidBrush(style.BorderColour), style.BorderWidth), area.ToGraphicsPath());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|