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 a new instance of the CompletionSession
class.
public CompletionSession()
Properties
AllowedCharacters
Gets or sets 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
- CharClass:
The CharClass containing the non-letter/digit characters allowed to be typed while the completion popup is displayed.
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
Gets the view-relative bounds of the session's open popup, if available.
public override Rect? Bounds { get; }
Property Value
CanCommitWithoutPopup
Gets or sets 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
- Boolean:
true
if 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
Gets or sets 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
- Boolean:
true
if 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
Gets or sets whether list items show possible matched characters in a highlight color.
public bool CanHighlightMatchedText { get; set; }
Property Value
- Boolean:
true
if list items show possible matched characters in a highlight color; otherwise,false
. The default value istrue
.
CanOpenForReadOnlyTextRanges
Gets whether the session is able to be opened for read-only text ranges.
protected override bool CanOpenForReadOnlyTextRanges { get; }
Property Value
- Boolean:
true
if the session is able to be opened for read-only text ranges; otherwise,false
. The default value isfalse
.
ClosesOnLostFocus
Returns whether this session auto-closes when the editor or any IntelliPrompt popups lose focus.
public override bool ClosesOnLostFocus { get; }
Property Value
- Boolean:
true
if this session auto-closes when the editor or any IntelliPrompt popups lose focus; otherwise,false
.
CommitCharacters
Gets or sets the CharClass containing the characters that can be typed when there is a full selection to trigger a Commit().
public CharClass CommitCharacters { get; set; }
Property Value
- CharClass:
The CharClass containing the characters that can be typed when there is a full selection to trigger a Commit().
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
Gets or sets an object that describes the context in which the completion session is opened.
public object Context { get; set; }
Property Value
- Object:
An object that describes the context in which the completion session is opened.
ControlKeyDownOpacity
Gets or sets the opacity of the popup while the control key is pressed.
public double ControlKeyDownOpacity { get; set; }
Property Value
- Double:
The opacity of the popup while the control key is pressed. The default value is
0.25
.
Remarks
Set the value to 1.0
to prevent opacity changes when the control key is pressed.
DescriptionTipMaxWidth
Gets or sets the description tip popup's maximum width.
public double DescriptionTipMaxWidth { get; set; }
Property Value
- Double:
The description tip popup's maximum width, or
NaN
to indicate no constraint. The default value is800
.
DescriptionTipShowDelay
Gets or sets the TimeSpan to wait after the selection is updated before showing the description tip.
public TimeSpan DescriptionTipShowDelay { get; set; }
Property Value
FilteredItems
Gets the read-only collection of filtered ICompletionItem objects that are visible within the completion list.
public ICompletionItemCollectionView FilteredItems { get; }
Property Value
- ICompletionItemCollectionView:
The read-only collection of filtered ICompletionItem objects that are visible within the completion list.
Filters
Gets the collection of ICompletionFilter objects that can be applied to the session.
public ICompletionFilterCollection Filters { get; }
Property Value
- ICompletionFilterCollection:
The collection of ICompletionFilter objects that can be applied to the session.
IsEnterKeyHandledOnCommit
Gets or sets 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
- Boolean:
true
if theEnter
key is handled (not allowed to insert a line feed) when it commits the session; otherwise,false
. The default value istrue
.
ItemMatchers
Gets the collection of ICompletionItemMatcher objects to use when matching items.
public ICompletionItemMatcherCollection ItemMatchers { get; }
Property Value
- ICompletionItemMatcherCollection:
The collection of ICompletionItemMatcher objects to use when matching items.
Items
Gets the collection of ICompletionItem objects within the completion.
public ICompletionItemCollection Items { get; }
Property Value
- ICompletionItemCollection:
The collection of ICompletionItem objects within the completion.
MatchOptions
Gets or sets the CompletionMatchOptions indicating the options to use when matching items.
public CompletionMatchOptions MatchOptions { get; set; }
Property Value
- CompletionMatchOptions:
The CompletionMatchOptions indicating the options to use when matching items.
PlacementRectangle
Gets the placement Rect, if known, around which the session should be placed.
protected virtual Rect? PlacementRectangle { get; }
Property Value
PlacementTarget
Gets the placement target for the session, if known.
protected virtual UIElement PlacementTarget { get; }
Property Value
- UIElement:
The placement target for the session, if known.
Remarks
The view will be used if this property returns null.
RequiresFilterOnTextChange
Gets or sets whether to apply filters when a text change occurs.
public bool RequiresFilterOnTextChange { get; set; }
Property Value
- Boolean:
true
if filters should be applied when a text change occurs; otherwise,false
. The default value isfalse
.
Selection
Gets a CompletionSelection indicating the current selection within the completion.
public CompletionSelection Selection { get; set; }
Property Value
- CompletionSelection:
A CompletionSelection indicating the current selection within the completion.
SessionType
Gets the IIntelliPromptSessionType that identifies the type of session.
public override IIntelliPromptSessionType SessionType { get; }
Property Value
- IIntelliPromptSessionType:
The IIntelliPromptSessionType that identifies the type of session.
TypedText
Gets the text that has been used to initialize the session and/or been entered by the end user since the session opened.
public string TypedText { get; }
Property Value
- String:
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
- IntelliPromptCompletionList:
The control that was created.
OnClosed(CancelEventArgs)
Raises the Closed
event.
protected override void OnClosed(CancelEventArgs e)
Parameter | Type | Description |
---|---|---|
e | CancelEventArgs | An |
OnCommitted(EventArgs)
Raises the Committed
event.
protected virtual void OnCommitted(EventArgs e)
Parameter | Type | Description |
---|---|---|
e | EventArgs | An |
OnCommitting(CancelEventArgs)
Raises the Committing
event.
protected virtual void OnCommitting(CancelEventArgs e)
Parameter | Type | Description |
---|---|---|
e | CancelEventArgs | An |
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 |
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 |
OnOpened(EventArgs)
Raises the Opened
event.
protected override void OnOpened(EventArgs e)
Parameter | Type | Description |
---|---|---|
e | EventArgs | An |
OnRequestNavigate(RequestNavigateEventArgs)
Raises the RequestNavigate
event.
protected virtual void OnRequestNavigate(RequestNavigateEventArgs e)
Parameter | Type | Description |
---|---|---|
e | RequestNavigateEventArgs | An |
OnSelectionChanged(EventArgs)
Raises the SelectionChanged
event.
protected virtual void OnSelectionChanged(EventArgs e)
Parameter | Type | Description |
---|---|---|
e | EventArgs | An |
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 |
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 |
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 InputPointerButtonEventArgs that contains 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 |
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 a custom 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.
RequestNavigate
Occurs when a hyperlink on a description tip is clicked that requests navigation.
SelectionChanged
Occurs after the Selection has changed.
Explicit Interface Implementations
IEditorDocumentTextChangeEventSink.NotifyDocumentTextChanged(SyntaxEditor, EditorSnapshotChangedEventArgs)
Notifies after a text change occurs to an IEditorDocument.
void IEditorDocumentTextChangeEventSink.NotifyDocumentTextChanged(SyntaxEditor editor, EditorSnapshotChangedEventArgs e)
Parameter | Type | Description |
---|---|---|
editor | SyntaxEditor | The SyntaxEditor whose IEditorDocument is changed. |
e | EditorSnapshotChangedEventArgs | The |
IEditorDocumentTextChangeEventSink.NotifyDocumentTextChanging(SyntaxEditor, EditorSnapshotChangingEventArgs)
Notifies before a text change occurs to an IEditorDocument.
void IEditorDocumentTextChangeEventSink.NotifyDocumentTextChanging(SyntaxEditor editor, EditorSnapshotChangingEventArgs e)
Parameter | Type | Description |
---|---|---|
editor | SyntaxEditor | The SyntaxEditor whose IEditorDocument that is changing. |
e | EditorSnapshotChangingEventArgs | The |
IEditorViewKeyInputEventSink.NotifyKeyDown(IEditorView, KeyEventArgs)
Notifies when a key is pressed down while focus is in the specified IEditorView.
void IEditorViewKeyInputEventSink.NotifyKeyDown(IEditorView view, KeyEventArgs e)
Parameter | Type | Description |
---|---|---|
view | IEditorView | The IEditorView that received the event. |
e | KeyEventArgs | The |
IEditorViewKeyInputEventSink.NotifyKeyUp(IEditorView, KeyEventArgs)
Notifies when a key is released while focus is in the specified IEditorView.
void IEditorViewKeyInputEventSink.NotifyKeyUp(IEditorView view, KeyEventArgs e)
Parameter | Type | Description |
---|---|---|
view | IEditorView | The IEditorView that received the event. |
e | KeyEventArgs | The |
IEditorViewPointerInputEventSink.NotifyPointerEntered(IEditorView, InputPointerEventArgs)
Occurs when the pointer enters the specified IEditorView.
void IEditorViewPointerInputEventSink.NotifyPointerEntered(IEditorView view, InputPointerEventArgs e)
Parameter | Type | Description |
---|---|---|
view | IEditorView | The IEditorView that received the event. |
e | InputPointerEventArgs | The InputPointerEventArgs that contains the event data. |
IEditorViewPointerInputEventSink.NotifyPointerExited(IEditorView, InputPointerEventArgs)
Occurs when the pointer leaves the specified IEditorView.
void IEditorViewPointerInputEventSink.NotifyPointerExited(IEditorView view, InputPointerEventArgs e)
Parameter | Type | Description |
---|---|---|
view | IEditorView | The IEditorView that received the event. |
e | InputPointerEventArgs | The InputPointerEventArgs that contains the event data. |
IEditorViewPointerInputEventSink.NotifyPointerHovered(IEditorView, InputPointerEventArgs)
Occurs when the pointer hovers over the specified IEditorView.
void IEditorViewPointerInputEventSink.NotifyPointerHovered(IEditorView view, InputPointerEventArgs e)
Parameter | Type | Description |
---|---|---|
view | IEditorView | The IEditorView that received the event. |
e | InputPointerEventArgs | The InputPointerEventArgs that contains the event data. |
IEditorViewPointerInputEventSink.NotifyPointerMoved(IEditorView, InputPointerEventArgs)
Occurs when the pointer moves within the specified IEditorView.
void IEditorViewPointerInputEventSink.NotifyPointerMoved(IEditorView view, InputPointerEventArgs e)
Parameter | Type | Description |
---|---|---|
view | IEditorView | The IEditorView that received the event. |
e | InputPointerEventArgs | The InputPointerEventArgs that contains the event data. |
IEditorViewPointerInputEventSink.NotifyPointerPressed(IEditorView, InputPointerButtonEventArgs)
Occurs when a pointer button is pressed over the specified IEditorView.
void IEditorViewPointerInputEventSink.NotifyPointerPressed(IEditorView view, InputPointerButtonEventArgs e)
Parameter | Type | Description |
---|---|---|
view | IEditorView | The IEditorView that received the event. |
e | InputPointerButtonEventArgs | The InputPointerButtonEventArgs that contains the event data. |
IEditorViewPointerInputEventSink.NotifyPointerReleased(IEditorView, InputPointerButtonEventArgs)
Occurs when a pointer button is released over the specified IEditorView.
void IEditorViewPointerInputEventSink.NotifyPointerReleased(IEditorView view, InputPointerButtonEventArgs e)
Parameter | Type | Description |
---|---|---|
view | IEditorView | The IEditorView that received the event. |
e | InputPointerButtonEventArgs | The InputPointerButtonEventArgs that contains the event data. |
IEditorViewPointerInputEventSink.NotifyPointerWheel(IEditorView, InputPointerWheelEventArgs)
Occurs when the pointer wheel is turned over the specified IEditorView.
void IEditorViewPointerInputEventSink.NotifyPointerWheel(IEditorView view, InputPointerWheelEventArgs e)
Parameter | Type | Description |
---|---|---|
view | IEditorView | The IEditorView that received the event. |
e | InputPointerWheelEventArgs | The InputPointerWheelEventArgs that contains the event data. |
IEditorViewSelectionChangeEventSink.NotifySelectionChanged(IEditorView, EditorViewSelectionEventArgs)
Notifies when the selection is changed in the specified IEditorView.
void IEditorViewSelectionChangeEventSink.NotifySelectionChanged(IEditorView view, EditorViewSelectionEventArgs e)
Parameter | Type | Description |
---|---|---|
view | IEditorView | The IEditorView that received the event. |
e | EditorViewSelectionEventArgs | The |
IEditorViewTextInputEventSink.NotifyTextInput(IEditorView, TextCompositionEventArgs)
Notifies before text is input to the specified IEditorView.
void IEditorViewTextInputEventSink.NotifyTextInput(IEditorView view, TextCompositionEventArgs e)
Parameter | Type | Description |
---|---|---|
view | IEditorView | The IEditorView that received the event. |
e | TextCompositionEventArgs | The |
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(Boolean)
- IntelliPromptSessionBase.OnServiceAdded(CollectionChangeEventArgs<Object>)
- IntelliPromptSessionBase.OnServiceRemoved(CollectionChangeEventArgs<Object>)
- IntelliPromptSessionBase.Open(IEditorView, TextRange)
- IntelliPromptSessionBase.GetPopupBounds(Popup)
- IntelliPromptSessionBase.IsOpen
- IntelliPromptSessionBase.SnapshotRange
- IntelliPromptSessionBase.SyncRoot
- IntelliPromptSessionBase.View
- IntelliPromptSessionBase.Closed
- IntelliPromptSessionBase.Opened
- IntelliPromptSessionBase.ServiceAdded
- IntelliPromptSessionBase.ServiceRemoved
- Object.ToString()
- Object.Equals(Object)
- Object.Equals(Object, Object)
- Object.ReferenceEquals(Object, Object)
- Object.GetHashCode()
- Object.GetType()
- Object.MemberwiseClone()