Table of Contents

Class TextFileViewModel

Namespace
Loehnert.Lisrt.Scripting.Editor.File.ViewModels
Assembly
Loehnert.Lisrt.Scripting.dll

View model for a text project item.

public class TextFileViewModel : PersistedDocument, IViewAware, IChild, ICommandHandler<UndoCommandDefinition>, ICommandHandler<RedoCommandDefinition>, ICommandHandler<SaveFileCommandDefinition>, ICommandHandler<SaveFileAsCommandDefinition>, ICommandHandler, IProjectItemDocument, IPersistedDocument, IDocument, ILayoutItem, IScreen, IHaveDisplayName, IActivate, IDeactivate, IGuardClose, IClose, INotifyPropertyChangedEx, INotifyPropertyChanged, IPersistedElement, IHandle<TextEditorSettingsChangedEvent>, IHandle
Inheritance
PropertyChangedBase
ViewAware
Screen
TextFileViewModel
Implements
IViewAware
IChild
IScreen
IHaveDisplayName
IActivate
IDeactivate
IGuardClose
IClose
INotifyPropertyChangedEx
IHandle
Derived
Inherited Members
Screen.OnActivate()
Screen.Parent
Screen.DisplayName
Screen.IsActive
Screen.IsInitialized
Screen.Activated
Screen.AttemptingDeactivation
Screen.Deactivated
ViewAware.DefaultContext
ViewAware.Views
ViewAware.ViewAttached
PropertyChangedBase.Refresh()
PropertyChangedBase.IsNotifying
PropertyChangedBase.PropertyChanged

Constructors

TextFileViewModel(IProjectItem, IEventAggregator, IScriptShell, IIntelliSenseService)

public TextFileViewModel(IProjectItem projectItem, IEventAggregator eventAggregator, IScriptShell shell, IIntelliSenseService intelliSenseService)

Parameters

projectItem IProjectItem

Text based project item (TextProjectItem).

eventAggregator IEventAggregator

Event aggregator for Caliburn.Micro.IHandle<TMessage>.

shell IScriptShell

Script shell.

intelliSenseService IIntelliSenseService

IntelliSense service, null for no IntelliSense.

Exceptions

ArgumentNullException

Thrown when projectItem, eventAggregator or shell is null.

ArgumentException

Thrown when projectItem is not of type TextProjectItem.

TextFileViewModel(IProjectItem, IEventAggregator, IScriptShell, IIntelliSenseService, ILockService, IUserManager, IMenuBuilder, IWindowManager)

Initializes a new instance of the TextFileViewModel class.

public TextFileViewModel(IProjectItem projectItem, IEventAggregator eventAggregator, IScriptShell shell, IIntelliSenseService intelliSenseService, ILockService lockService, IUserManager userManager, IMenuBuilder menuBuilder, IWindowManager windowManager)

Parameters

projectItem IProjectItem

Text based project item (TextProjectItem).

eventAggregator IEventAggregator

Event aggregator for Caliburn.Micro.IHandle<TMessage>.

shell IScriptShell

Script shell.

intelliSenseService IIntelliSenseService

IntelliSense service, null for no IntelliSense.

lockService ILockService

A service providing locks.

userManager IUserManager

Manager for users.

menuBuilder IMenuBuilder

Menu builder to build the context menu.

windowManager IWindowManager

Window manager to show dialogs.

Exceptions

ArgumentNullException

Thrown when projectItem, eventAggregator, shell, lockService or userManager is null.

ArgumentException

Thrown when projectItem is not of type TextProjectItem.

Properties

CaretPosition

Gets or sets the position of the caret.

public TextPosition CaretPosition { get; set; }

Property Value

TextPosition

ContextMenuItems

Gets the menu items for the context menu.

public IObservableCollection<MenuItemBase> ContextMenuItems { get; }

Property Value

IObservableCollection<MenuItemBase>

DefaultSettings

Gets the default settings.

protected virtual CodeEditorSettings DefaultSettings { get; }

Property Value

CodeEditorSettings

FileName

Gets the file name from the project item.

public override string FileName { get; }

Property Value

string

FilePath

Gets the file path of the project item. Is null if the path cannot be defined, for example if the ProjectItem doesn't belong to a project.

public override string FilePath { get; }

Property Value

string

GoToLineCommand

Gets the command to go to line.

public ICommand GoToLineCommand { get; }

Property Value

ICommand

IconSource

Gets the icon.

public override Uri IconSource { get; }

Property Value

Uri

IntelliSenseService

Gets the IntelliSense service. Can be null.

public IIntelliSenseService IntelliSenseService { get; }

Property Value

IIntelliSenseService

IsReadOnly

Gets a value indicating whether the control is read only.

public virtual bool IsReadOnly { get; }

Property Value

bool

Names

Gets the names (symbols) view model.

public NamesViewModel Names { get; }

Property Value

NamesViewModel

Options

Gets the editor options.

public CodeEditorOptions Options { get; }

Property Value

CodeEditorOptions

ProjectItem

Gets the TextProjectItem.

public IProjectItem ProjectItem { get; }

Property Value

IProjectItem

ResetUndoStackRequested

Gets or sets a value indicating whether a undo stack reset is requested.

public bool ResetUndoStackRequested { get; set; }

Property Value

bool

Selections

Gets or sets the text selection.

public ObservableCollection<TextSegment> Selections { get; set; }

Property Value

ObservableCollection<TextSegment>

Shell

Gets the shell.

protected IScriptShell Shell { get; }

Property Value

IScriptShell

ToolTip

Gets or sets the tool tip. Can be a string or a view model. Do not set this value.

public override object ToolTip { get; protected set; }

Property Value

object

Exceptions

NotSupportedException

Throw when the setter is called.

UserManager

Gets the user manager.

protected IUserManager UserManager { get; }

Property Value

IUserManager

Methods

DoLoad(string)

Loads the text from file with LoadFromFile().

protected override Task DoLoad(string filePath)

Parameters

filePath string

Path to load (not used, just for interface).

Returns

Task

Completed when completed.

Remarks

Prefer to use Load(string).

DoNew()

Creates a new item.

protected override Task DoNew()

Returns

Task

Completed when completed.

Exceptions

NotImplementedException

Always thrown.

DoSave(string)

Saves the project item to its file path.

protected override Task DoSave(string filePath)

Parameters

filePath string

Path for saving (not used, just for interface).

Returns

Task

Completed when completed.

Handle(TextEditorSettingsChangedEvent)

Handles the message for changed editor settings.

public virtual void Handle(TextEditorSettingsChangedEvent message)

Parameters

message TextEditorSettingsChangedEvent

The message.

OnDeactivate(bool)

Called when deactivating.

protected override void OnDeactivate(bool close)

Parameters

close bool

True, if the view is closed.

OnInitialize()

Called when initializing.

protected override void OnInitialize()

OnViewLoaded(object)

Called when an attached view's Loaded event fires.

protected override void OnViewLoaded(object view)

Parameters

view object

Loaded view.

Remarks

Registers with MahApps.Metro.Controls.Dialogs.DialogParticipation for the MetroDialogs and loads the text from file with DoLoad(string).

SelectLine(int)

Selects the line.

public void SelectLine(int line)

Parameters

line int

Number of the line.

SetCaretAtLine(int)

Sets the caret at the first non white space char of line.

public void SetCaretAtLine(int line)

Parameters

line int

Number of the line.

SetFileAsDirty()

Sets the file as dirty (IsDirty).

public virtual void SetFileAsDirty()