Class ModelViewController
The base controller to be used against all IModelView views in the system
Inheritance
Implements
Inherited Members
Namespace: LemonEdge.Client.Core.Views.Core
Assembly: LemonEdge.ClientCore.dll
Syntax
public abstract class ModelViewController : IModelViewController
Constructors
ModelViewController(IModelView)
Creates a new model view controller for the provided view from the client application ui
Declaration
public ModelViewController(IModelView view)
Parameters
Type | Name | Description |
---|---|---|
IModelView | view | The view this controller is responsible for |
Properties
CanWrite
Indicates if the user currently has permissions to edit the displayed item
Default to false if the main displayed item for this layout has read only set to true ( ReadOnly). Or loads the permissions for the item
Declaration
public virtual bool CanWrite { get; }
Property Value
Type | Description |
---|---|
bool |
CheckIsLockedForCanWrite
Indicates the controller should check if the item is locked before allowing CanWrite to be true. Defaults to true.
Declaration
protected virtual bool CheckIsLockedForCanWrite { get; }
Property Value
Type | Description |
---|---|
bool |
Commands
A list of all the custom commands that should be displayed in the client application alongside the View
Declaration
public IEnumerable<ViewCommand> Commands { get; }
Property Value
Type | Description |
---|---|
IEnumerable<ViewCommand> |
ContextHelpURL
An optional associated url of a help file for the view this controller works with
Declaration
public virtual string ContextHelpURL { get; }
Property Value
Type | Description |
---|---|
string |
CurrentDisplayedItem
The current item being displayed against the View. This is the item last called with DisplayableItemDescriptor
Declaration
public object CurrentDisplayedItem { get; }
Property Value
Type | Description |
---|---|
object |
DisplayIfNull
Indicates that even if the item is null the view should still update and display a null value. Default value is false.
Declaration
public virtual bool DisplayIfNull { get; }
Property Value
Type | Description |
---|---|
bool |
ListenToChanges
Indicates that this controller should be notified of changes made to any tracked item in this context via the OnTrackedItemChanged(object, string)
Declaration
public virtual bool ListenToChanges { get; }
Property Value
Type | Description |
---|---|
bool |
SelectedItemForSubViews
Returns the item this view holds that can be passed to sub views
This controller can change the item is passes to sub views (such as when this represents the selected item in a grid) by calling IModelLayoutDisplayerController.UpdateSubViews(IModelView)
Declaration
public virtual object SelectedItemForSubViews { get; }
Property Value
Type | Description |
---|---|
object |
TrackChanges
Indicates if changes to the item the view is displaying should be tracked - by default this is always true, but is overridden by views with extended controls to handle them individually
Declaration
public virtual bool TrackChanges { get; }
Property Value
Type | Description |
---|---|
bool |
View
The view instance this controller is working with
Declaration
public IModelView View { get; }
Property Value
Type | Description |
---|---|
IModelView |
Methods
AddHandlers(object)
Provides the implementing class an opportunity to add any handlers from the item
before it is
displayed by this controller
Declaration
protected virtual void AddHandlers(object item)
Parameters
Type | Name | Description |
---|---|---|
object | item | The item to add any handlers to |
Clear()
Clears the associated View back to an initial blank state
Declaration
public virtual Task Clear()
Returns
Type | Description |
---|---|
Task | A task indicating the completion of the operation |
CloseController()
Called when a view is being closed, and before the controller is disposed.
Used to dispose of associated commands and clear the view
Declaration
public virtual Task CloseController()
Returns
Type | Description |
---|---|
Task | A task indicating the completion of the operation |
DisplayItem(object)
Clears the view, determines if CanWrite is true, and if it ShouldDisplayItem(object) then calls AddHandlers(object) and DisplayUI()
Declaration
public virtual Task DisplayItem(object item)
Parameters
Type | Name | Description |
---|---|---|
object | item | The item to be displayed against this View |
Returns
Type | Description |
---|---|
Task | A task indicating the completion of the operation |
DisplayUI()
Must be implemented by the inheriting class to perform the operation of displaying the CurrentDisplayedItem against the View
Declaration
public abstract Task DisplayUI()
Returns
Type | Description |
---|---|
Task | A task indicating the completion of the operation |
GetCanWrite(object)
Declaration
protected virtual Task<bool> GetCanWrite(object item)
Parameters
Type | Name | Description |
---|---|---|
object | item |
Returns
Type | Description |
---|---|
Task<bool> |
GetCurrentDisplayedItem(object)
Declaration
protected virtual Task<object> GetCurrentDisplayedItem(object item)
Parameters
Type | Name | Description |
---|---|---|
object | item |
Returns
Type | Description |
---|---|
Task<object> |
InitAsync()
Provides the controller a chance to initialize any dependant data. Called once by the system after controller creation.
Declaration
public virtual Task InitAsync()
Returns
Type | Description |
---|---|
Task | A task indicating the completion of the operation |
InitCommands(IList<ViewCommand>)
Provides the inheriting class an opportunity to add custom commands to this controller
Declaration
protected virtual void InitCommands(IList<ViewCommand> commands)
Parameters
Type | Name | Description |
---|---|---|
IList<ViewCommand> | commands | The current set of commands for this controller |
InsertCommand(ViewCommand, ViewCommand, ViewCommand)
Inserts the specified command either directlyBefore
the specified command,
directlyAfter
the specified command, or just added to the end
Declaration
public virtual void InsertCommand(ViewCommand command, ViewCommand directlyAfter = null, ViewCommand directlyBefore = null)
Parameters
Type | Name | Description |
---|---|---|
ViewCommand | command | The command to insert into the existing set of commands for this controller |
ViewCommand | directlyAfter | The command this |
ViewCommand | directlyBefore | The command this |
InsertCommand(ViewCommand, int)
Inserts the specified command into the set of commands for this controller at the specified index location
Declaration
public virtual void InsertCommand(ViewCommand command, int index)
Parameters
Type | Name | Description |
---|---|---|
ViewCommand | command | The command to add to the list of commands for this controller |
int | index | The index location of the command to be added to the existing list of commands for this controller |
OnTrackedItemChanged(object, string)
Provides the inheriting class the opportunity to react to any changed item in the context this View operates within
Declaration
protected virtual void OnTrackedItemChanged(object item, string propName)
Parameters
Type | Name | Description |
---|---|---|
object | item | The item that has changed |
string | propName | The name of the property on the item that changed |
Redisplay()
Indicates the system should redisplay the CurrentDisplayedItem against the view again.
Usually a User initiated operation
Declaration
public virtual Task Redisplay()
Returns
Type | Description |
---|---|
Task | A task indicating the completion of the operation |
RemoveCommand(ViewCommand)
Removes the specified command from the set of commands for this controller
Declaration
public void RemoveCommand(ViewCommand command)
Parameters
Type | Name | Description |
---|---|---|
ViewCommand | command | The command to remove from the set of commands for this controller |
RemoveCommands<OFType>()
Removes all commands of the specified type OFType
from the set of commands for this
controller
Declaration
public void RemoveCommands<OFType>() where OFType : ViewCommand
Type Parameters
Name | Description |
---|---|
OFType | The type of commands to remove from the set of commands for this controller |
RemoveHandlers(object)
Provides the implementing class an opportunity to remove any handlers from the item
before its
reference is removed from this controller
Declaration
protected virtual void RemoveHandlers(object item)
Parameters
Type | Name | Description |
---|---|---|
object | item | The item to remove any handlers from |
ShouldDisplayItem(object)
Indicates if this item should be displayed against this view
By default this returns true if the item is not null or DisplayIfNull is true
Declaration
protected virtual bool ShouldDisplayItem(object item)
Parameters
Type | Name | Description |
---|---|---|
object | item | The item to check if it should be displayed against the View |
Returns
Type | Description |
---|---|
bool | True if this item should be displayed against this view |
UpdateAllCommands()
Enumerates all the commands for this controller and calls Commands.EPCommand.OnCanExecuteChanged
Used by the view to update the disabled/enabled state of all commands on the view when dependant data changes within the view itself
Declaration
public virtual void UpdateAllCommands()