Created
May 23, 2010 07:12
-
-
Save karno/410719 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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