diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KComboBox.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KComboBox.cs index 00aa0eb..8908746 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KComboBox.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KComboBox.cs @@ -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); diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KDataSource.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KDataSource.cs index 779738d..6c416c5 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KDataSource.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Controls/KDataSource.cs @@ -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 : 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; } } } diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/SharedFoldersDialog.Designer.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/SharedFoldersDialog.Designer.cs index ae3b9b3..8834769 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/SharedFoldersDialog.Designer.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/SharedFoldersDialog.Designer.cs @@ -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; diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/SharedFoldersDialog.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/SharedFoldersDialog.cs index 091fdff..bbf8edf 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/SharedFoldersDialog.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/SharedFoldersDialog.cs @@ -148,8 +148,12 @@ namespace Acacia.Features.SharedFolders }; FocusNode(node); } + kTreeFolders.Focus(); + } + else + { + gabLookup.FocusEdit(); } - kTreeFolders.Focus(); } private void dialogButtons_Apply(object sender, EventArgs e) diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/SharedFoldersDialog.resx b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/SharedFoldersDialog.resx index 2d9e44e..0e2826d 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/SharedFoldersDialog.resx +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/SharedFoldersDialog.resx @@ -148,7 +148,7 @@ 3, 0 - 105, 33 + 105, 29 0 @@ -171,26 +171,23 @@ 0 - - True - - - 1 - Fill - 3, 3 + 114, 3 200, 0 + + The user was not found + - + Start typing name - 256, 23 + 260, 23 0 @@ -202,44 +199,11 @@ Acacia.UI.GABLookupControl, Kopano, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null - _layoutCenterGABLookup - - - 0 - - - Fill - - - 113, 2 - - - 2, 2, 2, 2 - - - 3 - - - 262, 29 - - - 1 - - - _layoutCenterGABLookup - - - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - _layoutSelectUser - + 1 - - <?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> - True @@ -262,7 +226,7 @@ 8, 0, 8, 0 - 59, 27 + 59, 23 2 @@ -292,7 +256,7 @@ 1 - 442, 33 + 442, 29 0 @@ -310,16 +274,16 @@ 0 - <?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> + <?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> Fill - 3, 42 + 3, 38 - 442, 273 + 442, 277 0 @@ -658,7 +622,7 @@ 448, 418 - 3 + 0 _layoutMain @@ -685,7 +649,7 @@ 448, 418 - 4 + 0 @@ -721,7 +685,7 @@ 450, 35 - 0 + 1 dialogButtons diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/UI/GABLookupControl.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/UI/GABLookupControl.cs index 7781420..2eb4053 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/UI/GABLookupControl.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/UI/GABLookupControl.cs @@ -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 { 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)