From 72fa30189ee29fcb12aefd9900dcb7421466cd7d Mon Sep 17 00:00:00 2001
From: Patrick Simpson
Date: Wed, 21 Jun 2017 16:08:38 +0200
Subject: [PATCH] Exposed list properties on KComboBox
---
.../Controls/KAbstractComboBox.cs | 25 +++++++++-
.../AcaciaZPushPlugin/Controls/KComboBox.cs | 49 +++++++++++++++----
2 files changed, 63 insertions(+), 11 deletions(-)
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KAbstractComboBox.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KAbstractComboBox.cs
index e21a59a..d335623 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KAbstractComboBox.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KAbstractComboBox.cs
@@ -18,6 +18,29 @@ namespace Acacia.Controls
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
override public bool AutoSize { get { return base.AutoSize; } set { base.AutoSize = value; } }
+ [Category("Appearance")]
+ [Localizable(true)]
+ public string Placeholder
+ {
+ get { return _edit.Placeholder; }
+ set { _edit.Placeholder = value; }
+ }
+
+ [Category("Appearance")]
+ public Color PlaceholderColor
+ {
+ get { return _edit.PlaceholderColor; }
+ set { _edit.PlaceholderColor = value; }
+ }
+
+ [Category("Appearance")]
+ public Font PlaceholderFont
+ {
+ get { return _edit.PlaceholderFont; }
+ set { _edit.PlaceholderFont = value; }
+ }
+
+
#endregion
#region Components
@@ -35,7 +58,6 @@ namespace Acacia.Controls
_edit = new KTextBox();
_edit.BorderStyle = BorderStyle.None;
- _edit.Placeholder = "Test";
Controls.Add(_edit);
_state.AddControl(_edit);
_edit.TextChanged += _edit_TextChanged;
@@ -198,6 +220,7 @@ namespace Acacia.Controls
this._edit.Focus();
}
+ [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public bool DroppedDown
{
get
diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KComboBox.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KComboBox.cs
index 24391dd..463d29a 100644
--- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KComboBox.cs
+++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KComboBox.cs
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Drawing;
+using System.Drawing.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -10,37 +12,64 @@ namespace Acacia.Controls
{
public class KComboBox : KAbstractComboBox
{
- private readonly ListBox _dropList;
+ private readonly ListBox _list;
+
+ #region Items properties
+
+ [DefaultValue(true)]
+ [Localizable(true)]
+ [Category("Behavior")]
+ public bool IntegralHeight { get { return _list.IntegralHeight; } set { _list.IntegralHeight = value; } }
+
+ [DefaultValue(13)]
+ [Localizable(true)]
+ [Category("Behavior")]
+ public int ItemHeight { get { return _list.ItemHeight; } set { _list.ItemHeight = value; } }
+
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ [Editor("System.Windows.Forms.Design.ListControlStringCollectionEditor, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
+ [Localizable(true)]
+ [MergableProperty(false)]
+ [Category("Behavior")]
+ public ListBox.ObjectCollection Items { get { return _list.Items; } }
+
+ [DefaultValue(8)]
+ [Localizable(true)]
+ [Category("Behavior")]
+ public int MaxDropDownItems { get; set; }
+
+ #endregion
public KComboBox()
{
- _dropList = new ListBox();
- _dropList.IntegralHeight = true;
- DropControl = _dropList;
- _dropList.DisplayMember = "DisplayName"; // TODO: remove from here
+ MaxDropDownItems = 8;
+ _list = new ListBox();
+ _list.IntegralHeight = true;
+ DropControl = _list;
+ _list.DisplayMember = "DisplayName"; // TODO: remove from here
}
public void BeginUpdate()
{
- _dropList.BeginUpdate();
+ _list.BeginUpdate();
}
public void EndUpdate()
{
- _dropList.EndUpdate();
+ _list.EndUpdate();
}
public object DataSource
{
get
{
- return _dropList.DataSource;
+ return _list.DataSource;
}
set
{
- _dropList.BindingContext = new BindingContext();
- _dropList.DataSource = value;
+ _list.BindingContext = new BindingContext();
+ _list.DataSource = value;
}
}
}