CompletionSession Class
Represents an IntelliPrompt completion session.
public class CompletionSession : IntelliPromptSessionBase, ICompletionSession, IIntelliPromptSession, IServiceLocator, IEditorDocumentTextChangeEventSink, IEditorViewKeyInputEventSink, IEditorViewPointerInputEventSink, IEditorViewSelectionChangeEventSink, IEditorViewTextInputEventSink
- Inheritance:
- object IntelliPromptSessionBase object
- Derived:
- XmlCompletionSession
- Implements:
- ICompletionSession IIntelliPromptSession IServiceLocator IEditorDocumentTextChangeEventSink IEditorViewKeyInputEventSink IEditorViewPointerInputEventSink IEditorViewSelectionChangeEventSink IEditorViewTextInputEventSink
Constructors
CompletionSession()
Initializes an instance of the class.
public CompletionSession()
Properties
AllowedCharacters
The CharClass containing the non-letter/digit characters allowed to be typed while the completion popup is displayed.
public CharClass AllowedCharacters { get; set; }
Property Value
Remarks
All letter and digit characters are automatically allowed by the completion popup and therefore do not need to added to this property. This property should only contain additional non-letter/digit characters that need to be allowed.
When a character is typed, it's first checked to see if it's a letter, number, or is in the AllowedCharacters collection. If any of those cases is true, the character is entered into the editor and the session remains open. If instead the character is in the CommitCharacters collection and there is a full selection in the completion list, a Commit() occurs. Otherwise, the session is cancelled.
Bounds
The view-relative bounds of the session's open popup, if available.
CanCommitWithoutPopup
Indicates whether the session can immediately commit if a single match is made when the session is opened, commonly known as "complete word" functionality.
public bool CanCommitWithoutPopup { get; set; }
Property Value
- bool:
trueif the session can immediately commit if a single match is made when the session is opened; otherwise,false. The default value istrue.
Remarks
A value of false will force the popup list to always display, even if a single match is made upon open.
CanFilterUnmatchedItems
Indicates whether to filter out items that don't match the typed text, thereby shrinking the list of visible items.
public bool CanFilterUnmatchedItems { get; set; }
Property Value
- bool:
trueif items that don't match the typed text should be filtered out, thereby shrinking the list of visible items; otherwise,false. The default value isfalse.
CanHighlightMatchedText
Indicates whether list items show possible matched characters in a highlight color.
public bool CanHighlightMatchedText { get; set; }
Property Value
- bool:
trueif list items show possible matched characters in a highlight color; otherwise,false. The default value istrue.
CanOpenForReadOnlyTextRanges
Indicates whether the session is able to be opened for read-only text ranges.
protected override bool CanOpenForReadOnlyTextRanges { get; }
Property Value
- bool:
trueif the session is able to be opened for read-only text ranges; otherwise,false. The default value istrue.
ClosesOnLostFocus
Indicates whether this session auto-closes when the editor or any IntelliPrompt popups lose focus.
public override bool ClosesOnLostFocus { get; }
Property Value
- bool:
trueif this session auto-closes when the editor or any IntelliPrompt popups lose focus; otherwise,false.
CommitCharacters
The CharClass containing the characters that can be typed to trigger a Commit() when there is a full selection.
public CharClass CommitCharacters { get; set; }
Property Value
Remarks
The default value of this property is a CharClass that contains all characters.
When a character is typed, it's first checked to see if it's a letter, number, or is in the AllowedCharacters collection. If any of those cases is true, the character is entered into the editor and the session remains open. If instead the character is in the CommitCharacters collection and there is a full selection in the completion list, a Commit() occurs. Otherwise, the session is cancelled.
Context
An object that describes the context in which the completion session is opened.
ControlKeyDownOpacity
The opacity of the popup while the control key is pressed.
public double ControlKeyDownOpacity { get; set; }
Property Value
- double:
The default value is
0.25.
Remarks
Set the value to 1.0 to prevent opacity changes when the control key is pressed.
DescriptionTipMaxWidth
The description tip popup's maximum width.
public int DescriptionTipMaxWidth { get; set; }
Property Value
- int:
The description tip popup's maximum width, or
NaNto indicate no constraint. The default value is800.
DescriptionTipShowDelay
The TimeSpan to wait after the selection is updated before showing the description tip.
public TimeSpan DescriptionTipShowDelay { get; set; }
Property Value
- TimeSpan:
The default value is
400ms.
FilteredItems
The read-only collection of filtered ICompletionItem objects that are visible within the completion list.
public ICompletionItemCollectionView FilteredItems { get; }
Property Value
Filters
The collection of ICompletionFilter objects that can be applied to the session.
IsEnterKeyHandledOnCommit
Indicates whether the Enter key is handled (not allowed to insert a line feed) when it commits the session.
public bool IsEnterKeyHandledOnCommit { get; set; }
Property Value
- bool:
trueif theEnterkey is handled (not allowed to insert a line feed) when it commits the session; otherwise,false. The default value istrue.
ItemMatchers
The collection of ICompletionItemMatcher objects to use when matching items.
public ICompletionItemMatcherCollection ItemMatchers { get; }
Property Value
Items
The collection of ICompletionItem objects within the completion.
MatchOptions
The CompletionMatchOptions indicating the options to use when matching items.
PlacementRectangle
The placement Rectangle, if known, around which the session should be placed.
PlacementTarget
The placement target for the session, if known.
protected virtual IUIElement? PlacementTarget { get; }
Property Value
Remarks
The view will be used if this property returns null.
RequiresFilterOnTextChange
Indicates whether to apply filters when a text change occurs.
public bool RequiresFilterOnTextChange { get; set; }
Property Value
- bool:
trueif filters should be applied when a text change occurs; otherwise,false. The default value isfalse.
Selection
A CompletionSelection indicating the current selection within the completion.
SessionType
The IIntelliPromptSessionType that identifies the type of session.
public override IIntelliPromptSessionType SessionType { get; }
Property Value
TypedText
The text that has been used to initialize the session and/or been entered by the end user since the session opened.
Methods
ApplyFilters()
Re-applies the active filters and rebuilds the FilteredItems collection.
public void ApplyFilters()
Cancel()
Cancels the completion session.
public void Cancel()
CloseDescriptionTip()
Closes the description tip if it is open.
public void CloseDescriptionTip()
Commit()
Commits the completion session and performs an auto-complete if there is a Selection available.
public void Commit()
CreatePopupContent()
Creates an IntelliPromptCompletionList that is to be displayed in a popup.
protected virtual IntelliPromptCompletionList CreatePopupContent()
Returns
OnClosed(CancelEventArgs)
Raises the Closed event.
protected override void OnClosed(CancelEventArgs e)
| Parameter | Type | Description |
|---|---|---|
| e | CancelEventArgs | The event data. |
OnCommitted(EventArgs)
Raises the Committed event.
protected virtual void OnCommitted(EventArgs e)
| Parameter | Type | Description |
|---|---|---|
| e | EventArgs | The event data. |
OnCommitting(CancelEventArgs)
Raises the Committing event.
protected virtual void OnCommitting(CancelEventArgs e)
| Parameter | Type | Description |
|---|---|---|
| e | CancelEventArgs | The event data. |
OnDocumentTextChanged(SyntaxEditor, EditorSnapshotChangedEventArgs)
Occurs after a text change occurs to an IEditorDocument that uses this language.
protected virtual void OnDocumentTextChanged(SyntaxEditor editor, EditorSnapshotChangedEventArgs e)
| Parameter | Type | Description |
|---|---|---|
| editor | SyntaxEditor | The SyntaxEditor whose IEditorDocument is changed. |
| e | EditorSnapshotChangedEventArgs | The event data. |
OnDocumentTextChanging(SyntaxEditor, EditorSnapshotChangingEventArgs)
Occurs before a text change occurs to an IEditorDocument that uses this language.
protected virtual void OnDocumentTextChanging(SyntaxEditor editor, EditorSnapshotChangingEventArgs e)
| Parameter | Type | Description |
|---|---|---|
| editor | SyntaxEditor | The SyntaxEditor whose IEditorDocument is changed. |
| e | EditorSnapshotChangingEventArgs | The event data. |
OnOpened(EventArgs)
Raises the Opened event.
protected override void OnOpened(EventArgs e)
| Parameter | Type | Description |
|---|---|---|
| e | EventArgs | The event data. |
OnSelectionChanged(EventArgs)
Raises the SelectionChanged event.
protected virtual void OnSelectionChanged(EventArgs e)
| Parameter | Type | Description |
|---|---|---|
| e | EventArgs | The event data. |
OnViewKeyDown(IEditorView, KeyEventArgs)
Occurs when a key is pressed down while focus is in the specified IEditorView.
protected virtual void OnViewKeyDown(IEditorView view, KeyEventArgs e)
| Parameter | Type | Description |
|---|---|---|
| view | IEditorView | The IEditorView that received the event. |
| e | KeyEventArgs | The event data. |
OnViewKeyUp(IEditorView, KeyEventArgs)
Occurs when a key is released while focus is in the specified IEditorView.
protected virtual void OnViewKeyUp(IEditorView view, KeyEventArgs e)
| Parameter | Type | Description |
|---|---|---|
| view | IEditorView | The IEditorView that received the event. |
| e | KeyEventArgs | The event data. |
OnViewPointerPressed(IEditorView, InputPointerButtonEventArgs)
Occurs when a pointer button is pressed over the specified IEditorView.
protected virtual void OnViewPointerPressed(IEditorView view, InputPointerButtonEventArgs e)
| Parameter | Type | Description |
|---|---|---|
| view | IEditorView | The IEditorView that received the event. |
| e | InputPointerButtonEventArgs | The event data. |
OnViewSelectionChanged(IEditorView, EditorViewSelectionEventArgs)
Occurs when the selection is changed in the specified IEditorView.
protected virtual void OnViewSelectionChanged(IEditorView view, EditorViewSelectionEventArgs e)
| Parameter | Type | Description |
|---|---|---|
| view | IEditorView | The IEditorView that received the event. |
| e | EditorViewSelectionEventArgs | The event data. |
OnViewTextInput(IEditorView, TextCompositionEventArgs)
Occurs before text is input to the specified IEditorView.
protected virtual void OnViewTextInput(IEditorView view, TextCompositionEventArgs e)
| Parameter | Type | Description |
|---|---|---|
| view | IEditorView | The IEditorView that received the event. |
| e | TextCompositionEventArgs | The |
Open(IEditorView)
Opens the session, attaching to the specified IEditorView.
public void Open(IEditorView view)
| Parameter | Type | Description |
|---|---|---|
| view | IEditorView | The IEditorView in which the session is opened. |
Reposition()
Notifies the session that it should reposition its user interface.
public override void Reposition()
RestartDescriptionTipTimer()
Restarts the description tip display timer.
public void RestartDescriptionTipTimer()
SortItems()
Sorts the items in the session using the default sort comparer.
public void SortItems()
Remarks
Items should always be sorted before the session is opened for an optimal user experience. This method should be called to sort the items right before the session is opened if the items were not pre-sorted.
SortItems(IComparer<ICompletionItem>)
Sorts the items in the session using the default sort comparer.
public void SortItems(IComparer<ICompletionItem> comparer)
| Parameter | Type | Description |
|---|---|---|
| comparer | IComparer<ICompletionItem> | The IComparer<T> to use. |
Remarks
Items should always be sorted before the session is opened for an optimal user experience. This method should be called to sort the items right before the session is opened if the items were not pre-sorted.
TranslateTrackedSnapshotRange(TextSnapshotRange, ITextSnapshot)
Translates the TextSnapshotRange that is tracked for replacement to a range in a new ITextSnapshot.
protected virtual TextSnapshotRange TranslateTrackedSnapshotRange(TextSnapshotRange snapshotRange, ITextSnapshot targetSnapshot)
| Parameter | Type | Description |
|---|---|---|
| snapshotRange | TextSnapshotRange | The TextSnapshotRange to translate. |
| targetSnapshot | ITextSnapshot | The target ITextSnapshot. |
Returns
- TextSnapshotRange:
The translated TextSnapshotRange.
Events
Committed
Occurs after the session is committed.
Committing
Occurs before the session is committed, allowing it to be cancelled.
SelectionChanged
Occurs after the Selection has changed.
Inherited Members
- IntelliPromptSessionBase.GetAllServiceTypes()
- IntelliPromptSessionBase.GetService<T>()
- IntelliPromptSessionBase.GetService(object)
- IntelliPromptSessionBase.RegisterService<T>(T)
- IntelliPromptSessionBase.RegisterService(object, object)
- IntelliPromptSessionBase.UnregisterService<T>()
- IntelliPromptSessionBase.UnregisterService(object)
- IntelliPromptSessionBase.Close(bool)
- IntelliPromptSessionBase.OnServiceAdded(CollectionChangeEventArgs<object>)
- IntelliPromptSessionBase.OnServiceRemoved(CollectionChangeEventArgs<object>)
- IntelliPromptSessionBase.Open(IEditorView, TextRange?)
- IntelliPromptSessionBase.GetPopupBounds(PopupControl)
- IntelliPromptSessionBase.IsOpen
- IntelliPromptSessionBase.SnapshotRange
- IntelliPromptSessionBase.SyncRoot
- IntelliPromptSessionBase.View
- IntelliPromptSessionBase.Closed
- IntelliPromptSessionBase.Opened
- IntelliPromptSessionBase.ServiceAdded
- IntelliPromptSessionBase.ServiceRemoved
- object.GetType()
- object.MemberwiseClone()
- object.ToString()
- object.Equals(object)
- object.Equals(object, object)
- object.ReferenceEquals(object, object)
- object.GetHashCode()