Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save karno/410719 to your computer and use it in GitHub Desktop.

Select an option

Save karno/410719 to your computer and use it in GitHub Desktop.
private void ProcessStartSuggest(string text, int selectedStart)
{
if (String.IsNullOrEmpty(text) || selectedStart > text.Length || selectedStart < 1)
return;
System.Diagnostics.Debug.Assert(text != null, "Text is null.");
foreach (var c in SuggestCandidates)
{
if (text[selectedStart - 1] == c)
{
targetStart = selectedStart;
//Start suggest
Point displayOffset = this.GetPositionFromCharIndex(selectedStart);
//Get line height
int curLine = this.GetLineFromCharIndex(selectedStart);
float lineHeight = 0.0f;
System.Diagnostics.Debug.Assert(this.Font != null, "Font is null.");
switch (this.Font.Unit)
{
case GraphicsUnit.Display:
case GraphicsUnit.Pixel:
lineHeight = this.Font.Size;
break;
case GraphicsUnit.Document:
lineHeight = this.Font.Size / 300.0f * dpiY;
break;
case GraphicsUnit.Inch:
lineHeight = this.Font.Size * dpiY;
break;
case GraphicsUnit.Point:
lineHeight = this.Font.Size / 72.0f * dpiY;
break;
default:
throw new NotSupportedException("Unit " + this.Font.Unit.ToString() + " is not supported.");
}
System.Diagnostics.Debug.Assert(displayOffset != null, "DispOffset is null.");
//set display offset
displayOffset.Y += (int)Math.Ceiling(lineHeight);
sug = GetList(c, targetStart, this.PointToScreen(displayOffset));
if (sug == null)
return;
System.Diagnostics.Debug.Assert(sug != null, "Suggestor is null.");
sug.OnApplied += new Action(sug_OnApplied);
//親コントロールを探す
Control parent = this.Parent;
Form pf = null;
while (parent != null && (pf = parent as Form) == null)
parent = parent.Parent;
if (pf != null)
pf.AddOwnedForm(sug);
sug.Show();
this.Focus();
prevHit = c;
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment