Class TextFileViewModel
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
-
PropertyChangedBaseViewAwareScreenTextFileViewModel
- Implements
-
IViewAwareIChildIScreenIHaveDisplayNameIActivateIDeactivateIGuardCloseICloseINotifyPropertyChangedExIHandle<TextEditorSettingsChangedEvent>IHandle
- Derived
- Inherited Members
-
Screen.OnActivate()Screen.ParentScreen.DisplayNameScreen.IsActiveScreen.IsInitializedScreen.ActivatedScreen.AttemptingDeactivationScreen.DeactivatedViewAware.DefaultContextViewAware.ViewsViewAware.ViewAttachedPropertyChangedBase.Refresh()PropertyChangedBase.IsNotifyingPropertyChangedBase.PropertyChanged
Constructors
TextFileViewModel(IProjectItem, IEventAggregator, IScriptShell, IIntelliSenseService)
Initializes a new instance of the TextFileViewModel class. Calls TextFileViewModel(IProjectItem, IEventAggregator, IScriptShell, IIntelliSenseService, ILockService, IUserManager, IMenuBuilder, IWindowManager), with ILockService and IUserManager from Caliburn.Micro.IoC.
public TextFileViewModel(IProjectItem projectItem, IEventAggregator eventAggregator, IScriptShell shell, IIntelliSenseService intelliSenseService)
Parameters
projectItem
IProjectItemText based project item (TextProjectItem).
eventAggregator
IEventAggregatorEvent aggregator for Caliburn.Micro.IHandle<TMessage>.
shell
IScriptShellScript shell.
intelliSenseService
IIntelliSenseServiceIntelliSense service, null for no IntelliSense.
Exceptions
- ArgumentNullException
Thrown when
projectItem
,eventAggregator
orshell
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
IProjectItemText based project item (TextProjectItem).
eventAggregator
IEventAggregatorEvent aggregator for Caliburn.Micro.IHandle<TMessage>.
shell
IScriptShellScript shell.
intelliSenseService
IIntelliSenseServiceIntelliSense service, null for no IntelliSense.
lockService
ILockServiceA service providing locks.
userManager
IUserManagerManager for users.
menuBuilder
IMenuBuilderMenu builder to build the context menu.
windowManager
IWindowManagerWindow manager to show dialogs.
Exceptions
- ArgumentNullException
Thrown when
projectItem
,eventAggregator
,shell
,lockService
oruserManager
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
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
FileName
Gets the file name from the project item.
public override string FileName { get; }
Property Value
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
GoToLineCommand
Gets the command to go to line.
public ICommand GoToLineCommand { get; }
Property Value
IconSource
Gets the icon.
public override Uri IconSource { get; }
Property Value
IntelliSenseService
Gets the IntelliSense service. Can be null.
public IIntelliSenseService IntelliSenseService { get; }
Property Value
IsReadOnly
Gets a value indicating whether the control is read only.
public virtual bool IsReadOnly { get; }
Property Value
Names
Gets the names (symbols) view model.
public NamesViewModel Names { get; }
Property Value
Options
Gets the editor options.
public CodeEditorOptions Options { get; }
Property Value
ProjectItem
Gets the TextProjectItem.
public IProjectItem ProjectItem { get; }
Property Value
ResetUndoStackRequested
Gets or sets a value indicating whether a undo stack reset is requested.
public bool ResetUndoStackRequested { get; set; }
Property Value
Selections
Gets or sets the text selection.
public ObservableCollection<TextSegment> Selections { get; set; }
Property Value
Shell
Gets the shell.
protected IScriptShell Shell { get; }
Property Value
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
Exceptions
- NotSupportedException
Throw when the setter is called.
UserManager
Gets the user manager.
protected IUserManager UserManager { get; }
Property Value
Methods
DoLoad(string)
Loads the text from file with LoadFromFile().
protected override Task DoLoad(string filePath)
Parameters
filePath
stringPath to load (not used, just for interface).
Returns
Remarks
Prefer to use Load(string).
DoNew()
Creates a new item.
protected override Task DoNew()
Returns
Exceptions
- NotImplementedException
Always thrown.
DoSave(string)
Saves the project item to its file path.
protected override Task DoSave(string filePath)
Parameters
filePath
stringPath for saving (not used, just for interface).
Returns
Handle(TextEditorSettingsChangedEvent)
Handles the message for changed editor settings.
public virtual void Handle(TextEditorSettingsChangedEvent message)
Parameters
message
TextEditorSettingsChangedEventThe message.
OnDeactivate(bool)
Called when deactivating.
protected override void OnDeactivate(bool close)
Parameters
close
boolTrue, 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
objectLoaded 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
intNumber of the line.
SetCaretAtLine(int)
Sets the caret at the first non white space char of line
.
public void SetCaretAtLine(int line)
Parameters
line
intNumber of the line.
SetFileAsDirty()
Sets the file as dirty (IsDirty).
public virtual void SetFileAsDirty()