mirror of
https://github.com/netchx/netch.git
synced 2026-03-22 18:29:46 +08:00
:bug:修复模式选择下拉框的崩溃bug
This commit is contained in:
@@ -82,69 +82,76 @@ namespace System.Windows.Forms
|
||||
private object[] newList;
|
||||
private void ReevaluateCompletionList()
|
||||
{
|
||||
var currentSearchTerm = Text.ToLowerInvariant();
|
||||
if (currentSearchTerm == _previousSearchTerm) return;
|
||||
|
||||
_previousSearchTerm = currentSearchTerm;
|
||||
try
|
||||
{
|
||||
SuspendLayout();
|
||||
|
||||
var originalList = (object[])Tag;
|
||||
if (originalList == null)
|
||||
{
|
||||
Tag = originalList = Items.Cast<object>().ToArray();
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(currentSearchTerm))
|
||||
{
|
||||
if (Items.Count == originalList.Length) return;
|
||||
|
||||
newList = originalList;
|
||||
}
|
||||
else
|
||||
{
|
||||
newList = originalList.Where(x => x.ToString().ToLowerInvariant().Contains(currentSearchTerm)).ToArray();
|
||||
}
|
||||
var currentSearchTerm = Text.ToLowerInvariant();
|
||||
if (currentSearchTerm == _previousSearchTerm) return;
|
||||
|
||||
_previousSearchTerm = currentSearchTerm;
|
||||
try
|
||||
{
|
||||
while (Items.Count > 0)
|
||||
SuspendLayout();
|
||||
|
||||
var originalList = (object[])Tag;
|
||||
if (originalList == null)
|
||||
{
|
||||
Items.RemoveAt(0);
|
||||
Tag = originalList = Items.Cast<object>().ToArray();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(currentSearchTerm))
|
||||
{
|
||||
if (Items.Count == originalList.Length) return;
|
||||
|
||||
newList = originalList;
|
||||
}
|
||||
else
|
||||
{
|
||||
newList = originalList.Where(x => x.ToString().ToLowerInvariant().Contains(currentSearchTerm)).ToArray();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Items.Clear();
|
||||
while (Items.Count > 0)
|
||||
{
|
||||
Items.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
try
|
||||
{
|
||||
Items.Clear();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Items.AddRange(newList.ToArray());
|
||||
Items.AddRange(newList.ToArray());
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (currentSearchTerm.Length >= 2 && !DroppedDown)
|
||||
{
|
||||
DroppedDown = true;
|
||||
Cursor.Current = Cursors.Default;
|
||||
Text = currentSearchTerm;
|
||||
Select(currentSearchTerm.Length, 0);
|
||||
}
|
||||
|
||||
if (Items.Count > 0)
|
||||
{
|
||||
DroppedDown = false;
|
||||
DroppedDown = true;
|
||||
}
|
||||
|
||||
ResumeLayout(true);
|
||||
}
|
||||
}
|
||||
finally
|
||||
catch
|
||||
{
|
||||
if (currentSearchTerm.Length >= 2 && !DroppedDown)
|
||||
{
|
||||
DroppedDown = true;
|
||||
Cursor.Current = Cursors.Default;
|
||||
Text = currentSearchTerm;
|
||||
Select(currentSearchTerm.Length, 0);
|
||||
}
|
||||
|
||||
if (Items.Count > 0)
|
||||
{
|
||||
DroppedDown = false;
|
||||
DroppedDown = true;
|
||||
}
|
||||
|
||||
ResumeLayout(true);
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user