mirror of
https://github.com/Kopano-dev/kopano-ol-extension.git
synced 2023-10-10 13:37:40 +02:00
Implemented selection of GAB users. Added fallback item if no users are found.
This commit is contained in:
parent
d7c7c94a7e
commit
1b509495c8
@ -268,6 +268,16 @@ namespace Acacia.Controls
|
||||
_list.Items.Add(displayItem);
|
||||
}
|
||||
|
||||
if (_list.Items.Count == 0)
|
||||
{
|
||||
// Create a not-found item if requested
|
||||
object item = _dataSource.NotFoundItem;
|
||||
if (item != null)
|
||||
{
|
||||
_list.Items.Add(new DisplayItem(this, item));
|
||||
}
|
||||
}
|
||||
|
||||
// Select the current item only if new number of items is smaller. This means we don't keep selection
|
||||
// when the user is removing text, only when they are typing more.
|
||||
_list.ItemsChanged(_list.Items.Count < oldCount ? selected : -1);
|
||||
|
@ -23,6 +23,7 @@ namespace Acacia.Controls
|
||||
System.Collections.IEnumerable FilteredItems { get; }
|
||||
KDataFilter Filter { get; set; }
|
||||
string GetItemText(object item);
|
||||
object NotFoundItem { get; }
|
||||
}
|
||||
|
||||
abstract public class KDataSource<T> : KDataSourceRaw
|
||||
@ -73,6 +74,11 @@ namespace Acacia.Controls
|
||||
set;
|
||||
}
|
||||
|
||||
virtual public object NotFoundItem
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
IEnumerable KDataSourceRaw.Items { get{return Items;}}
|
||||
IEnumerable KDataSourceRaw.FilteredItems { get { return FilteredItems; } }
|
||||
}
|
||||
|
@ -35,7 +35,6 @@
|
||||
this._layoutMain = new System.Windows.Forms.TableLayoutPanel();
|
||||
this._layoutSelectUser = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.labelSelectUser = new System.Windows.Forms.Label();
|
||||
this._layoutCenterGABLookup = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.gabLookup = new Acacia.UI.GABLookupControl();
|
||||
this.buttonOpenUser = new System.Windows.Forms.Button();
|
||||
this.kTreeFolders = new Acacia.Controls.KTree();
|
||||
@ -53,7 +52,6 @@
|
||||
this._mainBusyHider.SuspendLayout();
|
||||
this._layoutMain.SuspendLayout();
|
||||
this._layoutSelectUser.SuspendLayout();
|
||||
this._layoutCenterGABLookup.SuspendLayout();
|
||||
this._layoutOptions.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@ -85,7 +83,7 @@
|
||||
//
|
||||
resources.ApplyResources(this._layoutSelectUser, "_layoutSelectUser");
|
||||
this._layoutSelectUser.Controls.Add(this.labelSelectUser, 0, 0);
|
||||
this._layoutSelectUser.Controls.Add(this._layoutCenterGABLookup, 1, 0);
|
||||
this._layoutSelectUser.Controls.Add(this.gabLookup, 1, 0);
|
||||
this._layoutSelectUser.Controls.Add(this.buttonOpenUser, 2, 0);
|
||||
this._layoutSelectUser.Name = "_layoutSelectUser";
|
||||
//
|
||||
@ -94,12 +92,6 @@
|
||||
resources.ApplyResources(this.labelSelectUser, "labelSelectUser");
|
||||
this.labelSelectUser.Name = "labelSelectUser";
|
||||
//
|
||||
// _layoutCenterGABLookup
|
||||
//
|
||||
resources.ApplyResources(this._layoutCenterGABLookup, "_layoutCenterGABLookup");
|
||||
this._layoutCenterGABLookup.Controls.Add(this.gabLookup, 0, 1);
|
||||
this._layoutCenterGABLookup.Name = "_layoutCenterGABLookup";
|
||||
//
|
||||
// gabLookup
|
||||
//
|
||||
this.gabLookup.DataSource = null;
|
||||
@ -221,8 +213,6 @@
|
||||
this._layoutMain.PerformLayout();
|
||||
this._layoutSelectUser.ResumeLayout(false);
|
||||
this._layoutSelectUser.PerformLayout();
|
||||
this._layoutCenterGABLookup.ResumeLayout(false);
|
||||
this._layoutCenterGABLookup.PerformLayout();
|
||||
this._layoutOptions.ResumeLayout(false);
|
||||
this._layoutOptions.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
@ -246,7 +236,6 @@
|
||||
private System.Windows.Forms.Label labelPermissionsValue;
|
||||
private Controls.KBusyHider _mainBusyHider;
|
||||
private Controls.KDialogButtons dialogButtons;
|
||||
private System.Windows.Forms.TableLayoutPanel _layoutCenterGABLookup;
|
||||
private UI.GABLookupControl gabLookup;
|
||||
private System.Windows.Forms.Label _labelReminders;
|
||||
private System.Windows.Forms.CheckBox checkReminders;
|
||||
|
@ -148,9 +148,13 @@ namespace Acacia.Features.SharedFolders
|
||||
};
|
||||
FocusNode(node);
|
||||
}
|
||||
}
|
||||
kTreeFolders.Focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
gabLookup.FocusEdit();
|
||||
}
|
||||
}
|
||||
|
||||
private void dialogButtons_Apply(object sender, EventArgs e)
|
||||
{
|
||||
|
@ -148,7 +148,7 @@
|
||||
<value>3, 0</value>
|
||||
</data>
|
||||
<data name="labelSelectUser.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>105, 33</value>
|
||||
<value>105, 29</value>
|
||||
</data>
|
||||
<data name="labelSelectUser.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>0</value>
|
||||
@ -171,26 +171,23 @@
|
||||
<data name=">>labelSelectUser.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name="_layoutCenterGABLookup.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="_layoutCenterGABLookup.ColumnCount" type="System.Int32, mscorlib">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="gabLookup.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
|
||||
<value>Fill</value>
|
||||
</data>
|
||||
<data name="gabLookup.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>3, 3</value>
|
||||
<value>114, 3</value>
|
||||
</data>
|
||||
<data name="gabLookup.MinimumSize" type="System.Drawing.Size, System.Drawing">
|
||||
<value>200, 0</value>
|
||||
</data>
|
||||
<data name="gabLookup.NotFoundText" xml:space="preserve">
|
||||
<value>The user was not found</value>
|
||||
</data>
|
||||
<data name="gabLookup.Placeholder" xml:space="preserve">
|
||||
<value />
|
||||
<value>Start typing name</value>
|
||||
</data>
|
||||
<data name="gabLookup.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>256, 23</value>
|
||||
<value>260, 23</value>
|
||||
</data>
|
||||
<data name="gabLookup.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>0</value>
|
||||
@ -202,44 +199,11 @@
|
||||
<value>Acacia.UI.GABLookupControl, Kopano, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null</value>
|
||||
</data>
|
||||
<data name=">>gabLookup.Parent" xml:space="preserve">
|
||||
<value>_layoutCenterGABLookup</value>
|
||||
</data>
|
||||
<data name=">>gabLookup.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name="_layoutCenterGABLookup.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
|
||||
<value>Fill</value>
|
||||
</data>
|
||||
<data name="_layoutCenterGABLookup.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>113, 2</value>
|
||||
</data>
|
||||
<data name="_layoutCenterGABLookup.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
|
||||
<value>2, 2, 2, 2</value>
|
||||
</data>
|
||||
<data name="_layoutCenterGABLookup.RowCount" type="System.Int32, mscorlib">
|
||||
<value>3</value>
|
||||
</data>
|
||||
<data name="_layoutCenterGABLookup.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>262, 29</value>
|
||||
</data>
|
||||
<data name="_layoutCenterGABLookup.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name=">>_layoutCenterGABLookup.Name" xml:space="preserve">
|
||||
<value>_layoutCenterGABLookup</value>
|
||||
</data>
|
||||
<data name=">>_layoutCenterGABLookup.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>_layoutCenterGABLookup.Parent" xml:space="preserve">
|
||||
<value>_layoutSelectUser</value>
|
||||
</data>
|
||||
<data name=">>_layoutCenterGABLookup.ZOrder" xml:space="preserve">
|
||||
<data name=">>gabLookup.ZOrder" xml:space="preserve">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="_layoutCenterGABLookup.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
|
||||
<value><?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="gabLookup" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,100" /><Rows Styles="Percent,50,AutoSize,0,Percent,50" /></TableLayoutSettings></value>
|
||||
</data>
|
||||
<data name="buttonOpenUser.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
</data>
|
||||
@ -262,7 +226,7 @@
|
||||
<value>8, 0, 8, 0</value>
|
||||
</data>
|
||||
<data name="buttonOpenUser.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>59, 27</value>
|
||||
<value>59, 23</value>
|
||||
</data>
|
||||
<data name="buttonOpenUser.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>2</value>
|
||||
@ -292,7 +256,7 @@
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="_layoutSelectUser.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>442, 33</value>
|
||||
<value>442, 29</value>
|
||||
</data>
|
||||
<data name="_layoutSelectUser.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>0</value>
|
||||
@ -310,16 +274,16 @@
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name="_layoutSelectUser.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
|
||||
<value><?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="labelSelectUser" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="_layoutCenterGABLookup" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="buttonOpenUser" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,100,AutoSize,0" /><Rows Styles="Percent,100,Absolute,33" /></TableLayoutSettings></value>
|
||||
<value><?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="labelSelectUser" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="gabLookup" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="buttonOpenUser" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,100,AutoSize,0" /><Rows Styles="Percent,100,Absolute,29" /></TableLayoutSettings></value>
|
||||
</data>
|
||||
<data name="kTreeFolders.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
|
||||
<value>Fill</value>
|
||||
</data>
|
||||
<data name="kTreeFolders.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>3, 42</value>
|
||||
<value>3, 38</value>
|
||||
</data>
|
||||
<data name="kTreeFolders.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>442, 273</value>
|
||||
<value>442, 277</value>
|
||||
</data>
|
||||
<data name="kTreeFolders.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>0</value>
|
||||
@ -658,7 +622,7 @@
|
||||
<value>448, 418</value>
|
||||
</data>
|
||||
<data name="_layoutMain.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>3</value>
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name=">>_layoutMain.Name" xml:space="preserve">
|
||||
<value>_layoutMain</value>
|
||||
@ -685,7 +649,7 @@
|
||||
<value>448, 418</value>
|
||||
</data>
|
||||
<data name="_mainBusyHider.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>4</value>
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name="_mainBusyHider.Text" type="System.Resources.ResXNullRef, System.Windows.Forms">
|
||||
<value />
|
||||
@ -721,7 +685,7 @@
|
||||
<value>450, 35</value>
|
||||
</data>
|
||||
<data name="dialogButtons.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>0</value>
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name=">>dialogButtons.Name" xml:space="preserve">
|
||||
<value>dialogButtons</value>
|
||||
|
@ -33,6 +33,13 @@ namespace Acacia.UI
|
||||
{
|
||||
public partial class GABLookupControl : KComboBoxCustomDraw
|
||||
{
|
||||
private class NotFoundGABUser : GABUser
|
||||
{
|
||||
public NotFoundGABUser(string userName) : base(userName)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private class GABDataSource : KDataSource<GABUser>
|
||||
{
|
||||
private readonly GABHandler _gab;
|
||||
@ -82,6 +89,14 @@ namespace Acacia.UI
|
||||
item.UserName?.ToLower().StartsWith(s) == true ||
|
||||
item.EmailAddress?.ToLower().StartsWith(s) == true;
|
||||
}
|
||||
|
||||
public override object NotFoundItem
|
||||
{
|
||||
get
|
||||
{
|
||||
return new NotFoundGABUser(Filter.FilterText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GABLookupControl() : this(null)
|
||||
@ -96,6 +111,15 @@ namespace Acacia.UI
|
||||
|
||||
#region Properties and events
|
||||
|
||||
|
||||
[Category("Appearance")]
|
||||
[Localizable(true)]
|
||||
public string NotFoundText
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
#region SelectedUser
|
||||
|
||||
public class SelectedUserEventArgs : EventArgs
|
||||
@ -202,7 +226,7 @@ namespace Acacia.UI
|
||||
|
||||
Size nameSize = TextRenderer.MeasureText(e.Graphics, item.FullName, Font);
|
||||
Size loginSize = TextRenderer.MeasureText(e.Graphics, item.UserName, Font);
|
||||
Size emailSize = TextRenderer.MeasureText(e.Graphics, item.EmailAddress, Font);
|
||||
Size emailSize = TextRenderer.MeasureText(e.Graphics, GetSecondLine(item), Font);
|
||||
|
||||
e.ItemWidth = Math.Max(emailSize.Width, nameSize.Width + loginSize.Width + NameSpacing.Width) +
|
||||
ItemPadding.Horizontal;
|
||||
@ -212,6 +236,14 @@ namespace Acacia.UI
|
||||
BorderThickness + BorderPadding.Vertical;
|
||||
}
|
||||
|
||||
private string GetSecondLine(GABUser item)
|
||||
{
|
||||
if (item is NotFoundGABUser)
|
||||
return NotFoundText;
|
||||
else
|
||||
return item.EmailAddress;
|
||||
}
|
||||
|
||||
protected override void OnDrawItem(DrawItemEventArgs e)
|
||||
{
|
||||
GABUser item = (GABUser)e.Item;
|
||||
@ -237,7 +269,8 @@ namespace Acacia.UI
|
||||
// Draw the email below
|
||||
pt.Y += Math.Max(nameSize.Height, loginSize.Height) + NameSpacing.Height;
|
||||
pt.X = e.Bounds.X + ItemPadding.Left;
|
||||
TextRenderer.DrawText(e.Graphics, item.EmailAddress, Font, pt, e.ForeColor);
|
||||
|
||||
TextRenderer.DrawText(e.Graphics, GetSecondLine(item), Font, pt, e.ForeColor);
|
||||
|
||||
// Draw a separator line
|
||||
if (e.Index < DisplayItemCount - 1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user