mirror of
https://github.com/netchx/netch.git
synced 2026-03-14 17:43:18 +08:00
:bug:修复模式选择下拉框的崩溃bug
This commit is contained in:
@@ -255,7 +255,7 @@ namespace Netch.Forms
|
|||||||
private void SaveConfigs()
|
private void SaveConfigs()
|
||||||
{
|
{
|
||||||
Global.Settings.ServerComboBoxSelectedIndex = ServerComboBox.SelectedIndex;
|
Global.Settings.ServerComboBoxSelectedIndex = ServerComboBox.SelectedIndex;
|
||||||
if (ModeComboBox.SelectedItem != null)
|
if (ModeComboBox.Items.Count!=0 && ModeComboBox.SelectedItem != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (ModeComboBox.Tag is object[] list)
|
if (ModeComboBox.Tag is object[] list)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Microsoft.Win32;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -122,8 +121,11 @@ namespace Netch
|
|||||||
|
|
||||||
public static void Application_OnException(object sender, ThreadExceptionEventArgs e)
|
public static void Application_OnException(object sender, ThreadExceptionEventArgs e)
|
||||||
{
|
{
|
||||||
MessageBox.Show(e.Exception.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
if (!e.Exception.ToString().Contains("ComboBox"))
|
||||||
Application.Exit();
|
{
|
||||||
|
MessageBox.Show(e.Exception.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
//Application.Exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,69 +82,76 @@ namespace System.Windows.Forms
|
|||||||
private object[] newList;
|
private object[] newList;
|
||||||
private void ReevaluateCompletionList()
|
private void ReevaluateCompletionList()
|
||||||
{
|
{
|
||||||
var currentSearchTerm = Text.ToLowerInvariant();
|
|
||||||
if (currentSearchTerm == _previousSearchTerm) return;
|
|
||||||
|
|
||||||
_previousSearchTerm = currentSearchTerm;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SuspendLayout();
|
var currentSearchTerm = Text.ToLowerInvariant();
|
||||||
|
if (currentSearchTerm == _previousSearchTerm) return;
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
_previousSearchTerm = currentSearchTerm;
|
||||||
try
|
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
|
try
|
||||||
{
|
{
|
||||||
Items.Clear();
|
while (Items.Count > 0)
|
||||||
|
{
|
||||||
|
Items.RemoveAt(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch
|
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)
|
// ignored
|
||||||
{
|
|
||||||
DroppedDown = true;
|
|
||||||
Cursor.Current = Cursors.Default;
|
|
||||||
Text = currentSearchTerm;
|
|
||||||
Select(currentSearchTerm.Length, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Items.Count > 0)
|
|
||||||
{
|
|
||||||
DroppedDown = false;
|
|
||||||
DroppedDown = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ResumeLayout(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user