Class BotViewModel
The view model for a scripted bot.
Inheritance
Implements
Inherited Members
Namespace: Phoenix.BotBrain
Assembly: Phoenix.Plugin.BotBrain.BotScripting.dll
Syntax
public class BotViewModel : BotViewModelBase, IBotViewModelWithActions, IBotViewModel, INotifyPropertyChanged, IOnSelected, ICanMoveItemsTo, IDisposable
Constructors
View SourceBotViewModel(IServiceProvider)
Initializes a new instance of the BotViewModel class.
Declaration
public BotViewModel(IServiceProvider services)
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceProvider | services | The service provider. |
Properties
View SourceActions
Gets the actions view model.
Declaration
public ListViewModel<IBotActionViewModel> Actions { get; }
Property Value
| Type | Description |
|---|---|
| ListViewModel<IBotActionViewModel> |
Bot
Gets or sets the bot being automated.
Declaration
public IAutomatedBot? Bot { get; protected set; }
Property Value
| Type | Description |
|---|---|
| IAutomatedBot |
Device
Gets or sets the device associated with the bot.
Declaration
public IDevice? Device { get; set; }
Property Value
| Type | Description |
|---|---|
| IDevice |
IsRunning
Gets a value indicating whether or not the bot is running.
Declaration
public override bool IsRunning { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Overrides
View SourceListViewTitle
Gets the title for the list view.
Declaration
public override string ListViewTitle { get; }
Property Value
| Type | Description |
|---|---|
| string |
Overrides
View SourceName
Gets or sets the bot's name.
Declaration
public override string? Name { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Overrides
View SourceSelectedAction
Gets or sets the selected action.
Declaration
public IBotActionViewModel? SelectedAction { get; set; }
Property Value
| Type | Description |
|---|---|
| IBotActionViewModel |
Status
Gets the bot's status.
Declaration
public override string Status { get; }
Property Value
| Type | Description |
|---|---|
| string |
Overrides
Methods
View SourceCanAppendItems(object)
Determines if the given items can be moved or copied into this object.
Declaration
public virtual bool CanAppendItems(object dragData)
Parameters
| Type | Name | Description |
|---|---|---|
| object | dragData | The items. |
Returns
| Type | Description |
|---|---|
| bool | A boolean. |
CheckAreActionsEditable()
Updates whether or not the actions are not editable.
Declaration
protected virtual void CheckAreActionsEditable()
ClearRunningAction()
Resets the currently running action.
Declaration
protected void ClearRunningAction()
CopyItemsTo(object)
Copies the given items into this object.
Declaration
public void CopyItemsTo(object dragData)
Parameters
| Type | Name | Description |
|---|---|---|
| object | dragData | The items. |
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public virtual void Dispose()
DisposeBot()
Disposes the bot in order to start a new one.
Declaration
protected virtual void DisposeBot()
DisposeBot(IAutomatedBot)
Disposes the bot.
Declaration
protected virtual void DisposeBot(IAutomatedBot bot)
Parameters
| Type | Name | Description |
|---|---|---|
| IAutomatedBot | bot | The bot. |
IsRunningOn(IDevice?)
Gets a value indicating whether or not the bot is running on the device.
Declaration
public override bool IsRunningOn(IDevice? device)
Parameters
| Type | Name | Description |
|---|---|---|
| IDevice | device | The device. |
Returns
| Type | Description |
|---|---|
| bool | True if it is running on the device. |
Overrides
View SourceLoad(string)
Loads a serialized representation of a bot.
Declaration
public override void Load(string data)
Parameters
| Type | Name | Description |
|---|---|---|
| string | data | The data to load. |
Overrides
View SourceMoveItemsTo(object)
Moves the given items into this object.
Declaration
public void MoveItemsTo(object dragData)
Parameters
| Type | Name | Description |
|---|---|---|
| object | dragData | The items. |
OnBotActionFailed(object?, BotActionFailedEventArgs)
Called when a bot action fails.
Declaration
protected virtual void OnBotActionFailed(object? sender, BotActionFailedEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| object | sender | The sender. |
| BotActionFailedEventArgs | e | Contains the action and exception. |
OnBotActionFinished(object?, BotActionEventArgs)
Called when a bot action finishes.
Declaration
protected virtual void OnBotActionFinished(object? sender, BotActionEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| object | sender | The sender. |
| BotActionEventArgs | e | Not used. |
OnBotActionStarted(object?, BotActionEventArgs)
Called when a bot action starts.
Declaration
protected virtual void OnBotActionStarted(object? sender, BotActionEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| object | sender | The sender. |
| BotActionEventArgs | e | Not used. |
OnCanExecuteChanged()
Handles UI updates when the bot's status changes.
Declaration
public override void OnCanExecuteChanged()
Overrides
View SourceRegisterBotEvents()
Registers bot events.
Declaration
protected virtual void RegisterBotEvents()
SaveToString()
Saves the bot to a string.
Declaration
protected override string SaveToString()
Returns
| Type | Description |
|---|---|
| string | A string representation of the bot. |
Overrides
View SourceSetRunningAction(int)
Sets the currently running action.
Declaration
protected void SetRunningAction(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The action index. |
SetRunningActions(IEnumerable<int>)
Sets the currently running actions.
Declaration
protected void SetRunningActions(IEnumerable<int> indices)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<int> | indices | The action indices. |
SetupBot()
Sets up the bot in order to start it.
Declaration
protected virtual Task SetupBot()
Returns
| Type | Description |
|---|---|
| Task | A task. |
StartAsync()
Starts the bot.
Declaration
public override Task StartAsync()
Returns
| Type | Description |
|---|---|
| Task | A task. |
Overrides
View SourceStopAsync()
Stops the bot.
Declaration
public override Task StopAsync()
Returns
| Type | Description |
|---|---|
| Task | A task. |