SmartTextBoxAdapter
Namespace: Wisej.AI.Adapters
Assembly: Wisej.AI
Enhances a TextBox control with several AI features, including suggestions, translation, and auto-correction.
- C#
- VB.NET
public class SmartTextBoxAdapter : SmartAdapter, IExtenderProvider
Public Class SmartTextBoxAdapter
Inherits SmartAdapter
Implements IExtenderProvider
This class extends the functionality of a standard TextBox by providing AI-driven features such as text suggestions, automatic translation between specified languages, and auto-correction of text input. It uses SmartPrompt sessions to interact with AI services.
Constructors
SmartTextBoxAdapter()
Initializes a new instanced of SmartTextBoxAdapter.
Properties
AcceptIconSource
String: Gets or sets the source of the icon displayed when a suggestion is accepted. (Default: null)
ProcessingIconSource
String: Gets or sets the source of the icon displayed during processing. (Default: "resource.wx/Wisej.AI/Icons/processing.svg")
SuggestionDelay
Int32: Gets or sets the delay in milliseconds before suggestions are shown. (Default: 250)
SuggestionStyle
String: Gets or sets the CSS style applied to suggestions. (Default: "opacity:0.4")
Methods
GetEnableAutoCorrection(control)
Determines whether the auto-correction feature is enabled for the specified control.
| Parameter | Type | Description |
|---|---|---|
| control | Control | The control to check. |
Returns: Boolean. True if auto-correction is enabled; otherwise, false.
Throws:
- ArgumentNullException Thrown when the control is null.
GetEnableSuggestions(control)
Determines whether the suggestions feature is enabled for the specified control.
| Parameter | Type | Description |
|---|---|---|
| control | Control | The control to check. |
Returns: Boolean. True if suggestions are enabled; otherwise, false.
Throws:
- ArgumentNullException Thrown when the control is null.
GetEnableTranslation(control)
Determines whether the translation feature is enabled for the specified control.
| Parameter | Type | Description |
|---|---|---|
| control | Control | The control to check. |
Returns: Boolean. True if translation is enabled; otherwise, false.
Throws:
- ArgumentNullException Thrown when the control is null.
GetTranslateFromLanguage(control)
Gets the source language for the translation feature associated with the specified control.
| Parameter | Type | Description |
|---|---|---|
| control | Control | The control from which to retrieve the source language. |
Returns: String. The source language as a string.
Throws:
- ArgumentNullException Thrown when the control is null.
GetTranslateToLanguage(control)
Gets the target language for the translation feature associated with the specified control.
| Parameter | Type | Description |
|---|---|---|
| control | Control | The control from which to retrieve the target language. |
Returns: String. The target language as a string.
Throws:
- ArgumentNullException Thrown when the control is null.
GetUserPhrases(control)
Gets the user-provided phrases associated with the specified control.
| Parameter | Type | Description |
|---|---|---|
| control | Control | The control from which to retrieve the user phrases. |
Returns: String[]. An array of user phrases.
Throws:
- ArgumentNullException Thrown when the control is null.
GetUserRole(control)
Gets the user role associated with the specified control.
| Parameter | Type | Description |
|---|---|---|
| control | Control | The control from which to retrieve the user role. |
Returns: String. The user role as a string.
Throws:
- ArgumentNullException Thrown when the control is null.
OnControlCreated(control)
| Parameter | Type | Description |
|---|---|---|
| control | Control |
OnControlDisposed(control)
| Parameter | Type | Description |
|---|---|---|
| control | Control |
RunAsyncCore(control)
| Parameter | Type | Description |
|---|---|---|
| control | Control |
Returns: Task<Message>.
SetEnableAutoCorrection(control, value)
| Parameter | Type | Description |
|---|---|---|
| control | Control | |
| value | Boolean |
SetEnableSuggestions(control, value)
| Parameter | Type | Description |
|---|---|---|
| control | Control | |
| value | Boolean |
SetEnableTranslation(control, value)
| Parameter | Type | Description |
|---|---|---|
| control | Control | |
| value | Boolean |
SetTranslateFromLanguage(control, value)
Sets the source language for the translation feature associated with the specified control.
| Parameter | Type | Description |
|---|---|---|
| control | Control | The control to associate with the source language. |
| value | String | The source language as a string. |
Throws:
- ArgumentNullException Thrown when the control is null.
SetTranslateToLanguage(control, value)
Sets the target language for the translation feature associated with the specified control.
| Parameter | Type | Description |
|---|---|---|
| control | Control | The control to associate with the target language. |
| value | String | The target language as a string. |
Throws:
- ArgumentNullException Thrown when the control is null.
SetUserPhrases(control, phrases)
| Parameter | Type | Description |
|---|---|---|
| control | Control | |
| phrases | String[] |
SetUserRole(control, value)
| Parameter | Type | Description |
|---|---|---|
| control | Control | |
| value | String |
Implements
| Name | Description |
|---|---|
| IToolProvider | Represents a provider that supplies tools. |