Skip to content

Commit

Permalink
Fixed an errr when trying to display a variable description from an e…
Browse files Browse the repository at this point in the history
…mpty or unselected row.

Extracted a new private method ShowVariableDescription() in the FrmMainW class.
  • Loading branch information
xvitaly committed Jul 28, 2024
1 parent b4da816 commit 4facc77
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions src/srcrepair/FrmMainW.cs
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,23 @@ private bool GetRepairSelState()
return PS_CleanPackages.Checked || PS_CleanRegistry.Checked || PS_ServiceRepair.Checked;
}

/// <summary>
/// Shows the description of the specified variable or function.
/// </summary>
/// <param name="Variable">Variable name.</param>
private void ShowVariableDescription(string Variable)
{
string Description = CvarFetcher.GetString(Variable);
if (!string.IsNullOrEmpty(Description))
{
MessageBox.Show(Description, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show(AppStrings.CE_ClNoDescr, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}

/// <summary>
/// Handles with installed FPS-configs and shows special icon.
/// </summary>
Expand Down Expand Up @@ -2649,22 +2666,21 @@ private void CE_ShowHint_Click(object sender, EventArgs e)
{
try
{
string Buf = CE_Editor.Rows[CE_Editor.CurrentRow.Index].Cells[0].Value.ToString();
if (!string.IsNullOrEmpty(Buf))
if (CE_Editor.SelectedCells.Count > 0)
{
Buf = CvarFetcher.GetString(Buf);
if (!string.IsNullOrEmpty(Buf))
DataGridViewCell Item = CE_Editor.Rows[CE_Editor.CurrentRow.Index].Cells[0];
if (!Item.OwningRow.IsNewRow && (Item.Value != null))
{
MessageBox.Show(Buf, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
ShowVariableDescription(Item.Value.ToString());
}
else
{
MessageBox.Show(AppStrings.CE_ClNoDescr, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
MessageBox.Show(AppStrings.CE_ClSelErr, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
else
{
MessageBox.Show(AppStrings.CE_ClSelErr, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
MessageBox.Show(AppStrings.CE_NoSelection, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
catch (Exception Ex)
Expand Down

0 comments on commit 4facc77

Please sign in to comment.