Compare commits

..

4 Commits

Author SHA1 Message Date
emoose
22d66d0aeb Revert "skip profile-scan if CSN-only"
Launch time improvement was only very minor, and caused modified profiles not to be loaded.
2026-01-19 01:29:30 +00:00
emoose
ceddf3d4ef Only search by exe name if entered profile name doesn't exist
This was meant to be happening automatically, but seems WinForms also decides
to send a KeyUp event with e.KeyCode == Keys.Enter when the user clicks an existing item (?)
2026-01-19 01:25:31 +00:00
emoose
f6d879f737 Show settings before profile-scan is complete
The old combobox code let the settings get displayed early but the combobox change had stopped that
2026-01-17 22:07:52 +00:00
emoose
3ac3447ecd Reduced launch time, set combobox datasource, skip profile-scan if CSN-only
For fastest launch enable the "Show from CustomSettingNames.xml only" button and close/relaunch.
2026-01-17 21:08:06 +00:00
2 changed files with 51 additions and 19 deletions

View File

@@ -178,8 +178,6 @@ namespace nspector.Common
var baseProfile = GetProfileInfo(hSession, hBase);
tmpBaseProfileName = baseProfile.profileName;
lstResult.Add("_GLOBAL_DRIVER_PROFILE (" + tmpBaseProfileName + ")");
var profileHandles = EnumProfileHandles(hSession);
foreach (IntPtr hProfile in profileHandles)
{
@@ -192,6 +190,11 @@ namespace nspector.Common
}
});
lstResult.Sort(StringComparer.OrdinalIgnoreCase);
// Insert the global profile at the start
lstResult.Insert(0, "_GLOBAL_DRIVER_PROFILE (" + tmpBaseProfileName + ")");
baseProfileName = tmpBaseProfileName;
return lstResult;
}

View File

@@ -41,6 +41,9 @@ namespace nspector
private bool _isDevMode = false;
private string[] _profileNames = new string[0];
private bool _comboBoxUpdating = false;
private UserSettings _settings = null;
protected override void WndProc(ref Message m)
@@ -230,12 +233,20 @@ namespace nspector
private void RefreshProfilesCombo()
{
cbProfiles.Items.Clear();
var combo = (ComboBox)cbProfiles.ComboBox;
var profileNames = _drs.GetProfileNames(ref _baseProfileName);
cbProfiles.Items.AddRange(profileNames.Cast<object>().ToArray());
_comboBoxUpdating = true;
try
{
_profileNames = _drs.GetProfileNames(ref _baseProfileName).ToArray();
cbProfiles.Sorted = true;
combo.DataSource = null;
combo.DataSource = _profileNames;
}
finally
{
_comboBoxUpdating = false;
}
}
private void MoveComboToItemAndFill()
@@ -632,6 +643,7 @@ namespace nspector
LoadSettings();
RefreshProfilesCombo();
RefreshCurrentProfile();
cbProfiles.Text = GetBaseProfileName();
tsbBitValueEditor.Enabled = false;
@@ -733,6 +745,11 @@ namespace nspector
private void cbProfiles_SelectedIndexChanged(object sender, EventArgs e)
{
if(_comboBoxUpdating)
{
return;
}
if (cbProfiles.SelectedIndex > -1)
{
ChangeCurrentProfile(cbProfiles.Text);
@@ -742,20 +759,27 @@ namespace nspector
private void cbProfiles_KeyUp(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter)
if (_comboBoxUpdating)
{
// KeyUp event is only fired when combobox item doesn't exist with the entered text
// Try searching for text as an exe/application name
try
return;
}
if (e.KeyCode == Keys.Enter)
{
// Search by exe name if the text isn't already a valid profile name
if (!_profileNames.Contains(cbProfiles.Text))
{
var profile = _drs.GetProfileNameByExeName(cbProfiles.Text);
if (!string.IsNullOrEmpty(profile))
try
{
cbProfiles.Text = profile;
ChangeCurrentProfile(profile);
var profile = _drs.GetProfileNameByExeName(cbProfiles.Text);
if (!string.IsNullOrEmpty(profile))
{
cbProfiles.Text = profile;
ChangeCurrentProfile(profile);
}
}
catch { }
}
catch { }
}
}
@@ -1101,7 +1125,7 @@ namespace nspector
private void ShowCreateProfileDialog(string nameProposal, string applicationName = null)
{
var ignoreList = cbProfiles.Items.Cast<string>().ToList();
var ignoreList = _profileNames.ToList();
string result = nameProposal;
if (InputBox.Show("Create Profile", "Please enter profile name:", ref result, ignoreList, "", 2048) == System.Windows.Forms.DialogResult.OK)
@@ -1110,7 +1134,7 @@ namespace nspector
{
_drs.CreateProfile(result, applicationName);
RefreshProfilesCombo();
cbProfiles.SelectedIndex = cbProfiles.Items.IndexOf(result);
cbProfiles.SelectedIndex = Array.IndexOf(_profileNames, result);
AddToModifiedProfiles(result, true);
}
catch (NvapiException ex)
@@ -1204,7 +1228,7 @@ namespace nspector
RefreshProfilesCombo();
await ScanProfilesSilentAsync(true, false);
int idx = cbProfiles.Items.IndexOf(_CurrentProfile);
int idx = Array.IndexOf(_profileNames, _CurrentProfile);
if (idx == -1 || _CurrentProfile == _baseProfileName)
cbProfiles.Text = GetBaseProfileName();
else
@@ -1247,6 +1271,11 @@ namespace nspector
private void cbProfiles_TextChanged(object sender, EventArgs e)
{
if (_comboBoxUpdating)
{
return;
}
if (cbProfiles.DroppedDown)
{
string txt = cbProfiles.Text;
@@ -1295,7 +1324,7 @@ namespace nspector
if (profiles != "")
{
var profile = profiles.Split(';')[0];
var idx = cbProfiles.Items.IndexOf(profile);
var idx = Array.IndexOf(_profileNames, profile);
if (idx > -1)
{
cbProfiles.SelectedIndex = idx;