1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- namespace System.Windows.Forms
- {
- public class ToolStripTextBox : ToolStripItem
- {
- private CustomControls.ToolStripTextBox textbox;
- public override string Text
- {
- get => textbox.Text;
- set => textbox.Text = value;
- }
- public bool AcceptsReturn
- {
- get => textbox.AcceptsReturn;
- set => textbox.AcceptsReturn = value;
- }
- public bool AcceptsTab
- {
- get => textbox.AcceptsTab;
- set => textbox.AcceptsTab = value;
- }
- public bool ReadOnly
- {
- get => textbox.IsReadOnly;
- set => textbox.IsReadOnly = value;
- }
- private HorizontalAlignment textBoxTextAlign;
- public HorizontalAlignment TextBoxTextAlign
- {
- get => textBoxTextAlign;
- set
- {
- textBoxTextAlign = value;
- textbox.HorizontalContentAlignment = value switch
- {
- HorizontalAlignment.Center => Windows.HorizontalAlignment.Center,
- HorizontalAlignment.Right => Windows.HorizontalAlignment.Right,
- _ => Windows.HorizontalAlignment.Left
- };
- }
- }
- public int MaxLength
- {
- get => textbox.MaxLength;
- set => textbox.MaxLength = value;
- }
- public override void ApplyStyle(ToolStripProfessionalRenderer r)
- {
- textbox.Resources["TextBox.ControlText"] = r.Foreground;
- textbox.Resources["TextBox.Static.Background"] = r.TextBoxStaticBackground;
- textbox.Resources["TextBox.Static.Border"] = r.ComboBoxStaticBorder;
- textbox.Resources["TextBox.MouseOver.Border"] = r.ComboBoxMouseOverBorder;
- textbox.Resources["TextBox.Disabled.Border"] = r.ComboBoxDisabledBorder;
- }
- public ToolStripTextBox()
- {
- textbox = new();
- SetControl(textbox);
- textbox.VerticalAlignment = VerticalAlignment.Center;
- textbox.TextChanged += (s, e) => OnTextChanged(e);
- AutoSize = false;
- }
- }
- }
|