In This Article

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

Rect?:

The view-relative bounds of the session's open popup, if available.

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

bool:

true if the session can immediately commit if a single match is made when the session is opened; otherwise, false. The default value is true.

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

bool:

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 is false.

CanHighlightMatchedText

Gets or sets whether list items show possible matched characters in a highlight color.

public bool CanHighlightMatchedText { get; set; }

Property Value

bool:

true if list items show possible matched characters in a highlight color; otherwise, false. The default value is true.

CanOpenForReadOnlyTextRanges

Gets whether the session is able to be opened for read-only text ranges.

protected override bool CanOpenForReadOnlyTextRanges { get; }

Property Value

bool:

true if the session is able to be opened for read-only text ranges; otherwise, false. The default value is false.

ClosesOnLostFocus

Returns whether this session auto-closes when the editor or any IntelliPrompt popups lose focus.

public override bool ClosesOnLostFocus { get; }

Property Value

bool:

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 is 800.

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

TimeSpan:

The TimeSpan to wait after the selection is updated before showing the description tip. The default value is 400ms.

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

bool:

true if the Enter key is handled (not allowed to insert a line feed) when it commits the session; otherwise, false. The default value is true.

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 System.Windows.Rect, if known, around which the session should be placed.

protected virtual Rect? PlacementRectangle { get; }

Property Value

Rect?:

The placement System.Windows.Rect, if known, around which the session should be placed.

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

bool:

true if filters should be applied when a text change occurs; otherwise, false. The default value is false.

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 CancelEventArgs that contains the event data.

OnCommitted(EventArgs)

Raises the Committed event.

protected virtual void OnCommitted(EventArgs e)
Parameter Type Description
e EventArgs

An EventArgs that contains the event data.

OnCommitting(CancelEventArgs)

Raises the Committing event.

protected virtual void OnCommitting(CancelEventArgs e)
Parameter Type Description
e CancelEventArgs

An CancelEventArgs that contains 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 EditorSnapshotChangedEventArgs that contains 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 EditorSnapshotChangingEventArgs that contains the event data.

OnOpened(EventArgs)

Raises the Opened event.

protected override void OnOpened(EventArgs e)
Parameter Type Description
e EventArgs

An EventArgs that contains the event data.

OnRequestNavigate(RequestNavigateEventArgs)

Raises the RequestNavigate event.

protected virtual void OnRequestNavigate(RequestNavigateEventArgs e)
Parameter Type Description
e RequestNavigateEventArgs

An RequestNavigateEventArgs that contains the event data.

OnSelectionChanged(EventArgs)

Raises the SelectionChanged event.

protected virtual void OnSelectionChanged(EventArgs e)
Parameter Type Description
e EventArgs

An EventArgs that contains 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 KeyEventArgs that contains 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 KeyEventArgs that contains 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 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 EditorViewSelectionEventArgs that contains 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 TextCompositionEventArgs that contains the event data.

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.

public event EventHandler Committed

Event Type

EventHandler

Committing

Occurs before the session is committed, allowing it to be cancelled.

public event EventHandler<CancelEventArgs> Committing

Event Type

EventHandler<CancelEventArgs>

RequestNavigate

Occurs when a hyperlink on a description tip is clicked that requests navigation.

public event RequestNavigateEventHandler RequestNavigate

Event Type

RequestNavigateEventHandler

SelectionChanged

Occurs after the Selection has changed.

public event EventHandler SelectionChanged

Event Type

EventHandler

Inherited Members