private bool AddReconversionItems(TextEditor textEditor) { MenuItem menuItem; TextStore textStore = textEditor.TextStore; if (textStore == null) { GC.SuppressFinalize(this); return(false); } ReleaseCandidateList(null); _candidateList = new SecurityCriticalDataClass <UnsafeNativeMethods.ITfCandidateList>(textStore.GetReconversionCandidateList()); if (CandidateList == null) { GC.SuppressFinalize(this); return(false); } int count = 0; CandidateList.GetCandidateNum(out count); if (count > 0) { // Like Winword, we show the first 5 candidates in the context menu. int i; for (i = 0; i < 5 && i < count; i++) { string suggestion; UnsafeNativeMethods.ITfCandidateString candString; CandidateList.GetCandidate(i, out candString); candString.GetString(out suggestion); menuItem = new ReconversionMenuItem(this, i); menuItem.Header = suggestion; menuItem.InputGestureText = GetMenuItemDescription(suggestion); this.Items.Add(menuItem); Marshal.ReleaseComObject(candString); } } // Like Winword, we show "More" menu to open TIP's candidate list if there are more // than 5 candidates. if (count > 5) { menuItem = new EditorMenuItem(); menuItem.Header = SR.Get(SRID.TextBox_ContextMenu_More); menuItem.Command = ApplicationCommands.CorrectionList; this.Items.Add(menuItem); menuItem.CommandTarget = textEditor.UiScope; } return((count > 0) ? true : false); }
private bool AddReconversionItems(TextEditor textEditor) { TextStore textStore = textEditor.TextStore; if (textStore == null) { GC.SuppressFinalize(this); return(false); } this.ReleaseCandidateList(null); this._candidateList = new SecurityCriticalDataClass <UnsafeNativeMethods.ITfCandidateList>(textStore.GetReconversionCandidateList()); if (this.CandidateList == null) { GC.SuppressFinalize(this); return(false); } int num = 0; this.CandidateList.GetCandidateNum(out num); if (num > 0) { int num2 = 0; while (num2 < 5 && num2 < num) { UnsafeNativeMethods.ITfCandidateString tfCandidateString; this.CandidateList.GetCandidate(num2, out tfCandidateString); string text; tfCandidateString.GetString(out text); MenuItem menuItem = new TextEditorContextMenu.ReconversionMenuItem(this, num2); menuItem.Header = text; menuItem.InputGestureText = this.GetMenuItemDescription(text); base.Items.Add(menuItem); Marshal.ReleaseComObject(tfCandidateString); num2++; } } if (num > 5) { MenuItem menuItem = new TextEditorContextMenu.EditorMenuItem(); menuItem.Header = SR.Get("TextBox_ContextMenu_More"); menuItem.Command = ApplicationCommands.CorrectionList; base.Items.Add(menuItem); menuItem.CommandTarget = textEditor.UiScope; } return(num > 0); }