public void ShowSuplDialog(TextBox owner, AtIdSupplement dialog, int offset, string startswith)
{
dialog.StartsWith = startswith;
if (dialog.Visible)
{
dialog.Focus();
}
else
{
dialog.ShowDialog();
}
this.TopMost = this._cfgCommon.AlwaysTop;
int selStart = owner.SelectionStart;
string fHalf = "";
string eHalf = "";
if (dialog.DialogResult == DialogResult.OK)
{
if (!string.IsNullOrEmpty(dialog.inputText))
{
if (selStart > 0)
{
fHalf = owner.Text.Substring(0, selStart - offset);
}
if (selStart < owner.Text.Length)
{
eHalf = owner.Text.Substring(selStart);
}
owner.Text = fHalf + dialog.inputText + eHalf;
owner.SelectionStart = selStart + dialog.inputText.Length;
}
}
else
{
if (selStart > 0)
{
fHalf = owner.Text.Substring(0, selStart);
}
if (selStart < owner.Text.Length)
{
eHalf = owner.Text.Substring(selStart);
}
owner.Text = fHalf + eHalf;
if (selStart > 0)
{
owner.SelectionStart = selStart;
}
}
owner.Focus();
}