Class ModelLayoutDisplayerController
The main controller for any IModelLayoutDisplayer ui cclient application component that contains a custom layout and is responsible for displaying and working with an item
Inheritance
Implements
Inherited Members
Namespace: LemonEdge.Client.Core.Views.Core
Assembly: ClientCore.dll
Syntax
public class ModelLayoutDisplayerController : IDisposable
Constructors
ModelLayoutDisplayerController(IModelLayoutDisplayer)
Creates a new model layout displayer controller for the client application instance of the displayer
ui component
Declaration
public ModelLayoutDisplayerController(IModelLayoutDisplayer displayer)
Parameters
Type | Name | Description |
---|---|---|
IModelLayoutDisplayer | displayer | The ui component of the IModelLayoutDisplayer in the client application |
Properties
Displayer
The ui specific client implementation of the displayer this controller is responsible for
Declaration
public IModelLayoutDisplayer Displayer { get; }
Property Value
Type | Description |
---|---|
IModelLayoutDisplayer |
HasOwnDisplayer
Indicates that this controller should not handle enumerating all the views within a tab and correctly displaying the items for them
Some client applications (such as single threaded console app) override the display of a tab and enumerate the view displays themselves, this returns true if that is the case
To provide an override you can call SetTabDisplayHandler(Func<LayoutTabSetting, Task>)Declaration
public bool HasOwnDisplayer { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Layout
The actual layout designer for this layout that has been generated (DefaultLayoutGenerator) or loaded (ILayout) or designed (LayoutDesigner) into this Displayer
Declaration
public LayoutDescriptor Layout { get; }
Property Value
Type | Description |
---|---|
LayoutDescriptor |
LayoutID
Holds the id of a custom ILayout that the system will use to load the layout for this displayer dynamically
This is also used by the layout designer. When it creates a new layout, it stores the id here so it can be retrieved from the context when switching between layouts
Declaration
public Guid? LayoutID { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Guid> |
LayoutName
Declaration
public string LayoutName { get; set; }
Property Value
Type | Description |
---|---|
System.String |
LayoutURL
The url for help on this particular layout retrieved from either the LayoutHelpURL or LayoutHelpURL depending on how the layout was loaded
Declaration
public string LayoutURL { get; }
Property Value
Type | Description |
---|---|
System.String |
MainDisplayedItem
The main displayed item this layout is responsible for displaying in all the top level views contained within the layout for this Displayer
Declaration
public DisplayableItemDescriptor MainDisplayedItem { get; }
Property Value
Type | Description |
---|---|
DisplayableItemDescriptor |
SelectedTab
The currently active selected tab in the layout displayer ui
Declaration
public LayoutTabSetting SelectedTab { get; }
Property Value
Type | Description |
---|---|
LayoutTabSetting |
SetColor
The colour to display this displayer with in the client application ui and the host IModelLayouHost.
A displayer only has a colour if it is sharing a context with another Displayer so the user can easily see the relationship between the different layouts
The default returned is just defaultDeclaration
public Color SetColor { get; }
Property Value
Type | Description |
---|---|
System.Drawing.Color |
Tabs
A list of all the tabs to be displayed visually to the user in the Displayer that have been loaded for the layout for this layout displayer
Declaration
public IEnumerable<LayoutTabSetting> Tabs { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<LayoutTabSetting> |
Methods
AddTab()
Adds a new tab to the layout for this displayer
Declaration
public LayoutTabSetting AddTab()
Returns
Type | Description |
---|---|
LayoutTabSetting | The descriptor of the new tab that has been added to the layout |
AddTrackedItemListener(TrackedItemChange)
Registers a listener that will be notified by this layout displayer if any tracked item (via TrackItem(INotifyPropertyChanged)) has changed
Declaration
public void AddTrackedItemListener(TrackedItemChange listener)
Parameters
Type | Name | Description |
---|---|---|
TrackedItemChange | listener | The listener to notify whenever a tracked item has changed |
AddView(LayoutTabSetting, ViewDescriptorInstance)
Adds the specified view to the specified tab in this layout displayer
Declaration
public LayoutViewDescriptor AddView(LayoutTabSetting fromTab, ViewDescriptorInstance view)
Parameters
Type | Name | Description |
---|---|---|
LayoutTabSetting | fromTab | The tab to add the specified view to |
ViewDescriptorInstance | view | The view to be added to the layout of the specified tab |
Returns
Type | Description |
---|---|
LayoutViewDescriptor | The view that has been added to the tab |
Close(Boolean)
Closes this layout and removes it from the parent IModelLayouHost
Declaration
public Task<bool> Close(bool silent = false)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | silent | If false indicates the user should be prompted about saving if this layout contains any pending changes |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | A task indicating the completion of the operation |
CloseController()
Called when this layout is being closed, and removed from the IModelLayouHost
Used to dispose of all views, controllers, commands and other resources
Declaration
public Task CloseController()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of the operation |
DeleteCurrentTab()
Removes the current selected tab from the layout in the displayer
Declaration
public LayoutTabSetting DeleteCurrentTab()
Returns
Type | Description |
---|---|
LayoutTabSetting | The descriptor of the tab that has been removed |
DeleteView(LayoutTabSetting, ViewDescriptorInstance)
Indicates the specified view within the specified tab should be removed from the display, including any dependant child views
Declaration
public IEnumerable<ViewDescriptorInstance> DeleteView(LayoutTabSetting fromTab, ViewDescriptorInstance view)
Parameters
Type | Name | Description |
---|---|---|
LayoutTabSetting | fromTab | |
ViewDescriptorInstance | view |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ViewDescriptorInstance> | The view that is removed from this layout |
DisplayItem(DisplayableItemDescriptor)
Sets the specified item as the main displayed item for this layout and displays it against every visible view for the user
If a layout has no been loaded yet the system will load the default layout (or custom, or overriden/provided one) and load the layout first before displaying the item against all visible views
Declaration
public Task DisplayItem(DisplayableItemDescriptor item)
Parameters
Type | Name | Description |
---|---|---|
DisplayableItemDescriptor | item | The item to display against this displayer |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of the operation |
DisplayView(LayoutViewDescriptor)
Displays the correct item to display against the specified view by passing that item in to the DisplayItem(Object) method
Also checks if the item is valid against the specified view type. If it is not the system will display a message to the user that the view is invalid for displaying the specified item type
Declaration
public Task DisplayView(LayoutViewDescriptor view)
Parameters
Type | Name | Description |
---|---|---|
LayoutViewDescriptor | view | The view to display the correct item for |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the cimpletion of the operation |
Dispose()
Declaration
public void Dispose()
Dispose(Boolean)
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
FireLayoutContentChanged(Object, String)
Re-evaluates any formulas within the layout settings (Tabs, Groups or Views) that may have changed value due to the specified changed item/property
Then notifies every registered listener of the item change, along with notifying the IModelLayouHost that the layout itself may have changed
Declaration
public void FireLayoutContentChanged(object changedItem, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.Object | changedItem | The source of the item that has changed |
System.String | propertyName | The name of the property that has changed on the |
FireTrackedItemListeners()
Notifies every registered listener that there has been a change by sending this and a property name of "" as the change
This is useful for listeners that do not care what changed (such as ui listeners to indicate that there are context changes in a layout), simply that there maybe a change to check
Declaration
public void FireTrackedItemListeners()
GetItemForViewToDisplay(ViewDescriptorInstance)
Returns the item that the specified view should be using to display.
If this view has a parent then it will retrieve the SelectedItemForSubViews item to display, otherwise it will use the main displayed item (Item) for this entire layout
Declaration
public object GetItemForViewToDisplay(ViewDescriptorInstance viewDescriptor)
Parameters
Type | Name | Description |
---|---|---|
ViewDescriptorInstance | viewDescriptor | The view to retrieve the item that it should be displaying |
Returns
Type | Description |
---|---|
System.Object | The item that should be displayed against the specified |
GetView(ViewDescriptorInstance)
Returns the actual view for the specified view descriptor within this loaded layout
Declaration
public IModelView GetView(ViewDescriptorInstance descriptor)
Parameters
Type | Name | Description |
---|---|---|
ViewDescriptorInstance | descriptor | The view descriptor to return the created view instance of |
Returns
Type | Description |
---|---|
IModelView | The actual view for the specified view descriptor within this loaded layout |
GetViewDescriptors(LayoutTabSetting)
Returns a list of all the view descriptors for the specified tab for the loaded layout
Declaration
public IEnumerable<ViewDescriptorInstance> GetViewDescriptors(LayoutTabSetting forTab)
Parameters
Type | Name | Description |
---|---|---|
LayoutTabSetting | forTab | The tab to return all the view descriptors within |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ViewDescriptorInstance> | A list of all the view descriptors for the specified tab for the loaded layout |
GetViews(LayoutTabSetting)
Returns a list of all the views within the specified tab for the loaded layout
Declaration
public IEnumerable<IModelView> GetViews(LayoutTabSetting forTab)
Parameters
Type | Name | Description |
---|---|---|
LayoutTabSetting | forTab | The tab to return all the views within |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IModelView> | A list of all the views within the specified tab for the loaded layout |
MoveTabLeft()
Moves the current selected tab to the left in the layout
Declaration
public LayoutTabSetting MoveTabLeft()
Returns
Type | Description |
---|---|
LayoutTabSetting | The current tab being moved to the left |
MoveTabRight()
Moves the current selected tab to the right in the layout
Declaration
public LayoutTabSetting MoveTabRight()
Returns
Type | Description |
---|---|
LayoutTabSetting | The current tab being moved to the right |
OnTabSelected(LayoutTabSetting)
Used by the Displayer to inform the controller that the user has selected a new tab in the layout
The controller will then dynamically load the layout for the tab (if it has not already been loaded) and ensure all the visible views in it have the correct item displayed
Declaration
public Task OnTabSelected(LayoutTabSetting tabSetting)
Parameters
Type | Name | Description |
---|---|---|
LayoutTabSetting | tabSetting | The tab that is now the active tab in the layout |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Redisplay()
Enumerates through all the visible top level views and redisplays (calling Redisplay()) the main item they should be displaying.
As those views load and select any output entity, that will cascade down to any child views too
Declaration
public Task Redisplay()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of the operation |
Refresh()
Causes the display for this layout to be refreshed. This will reload the MainDisplayItem (via Recreate()), and then redisplay the item against all visible views
Declaration
public Task Refresh()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of the operation |
SetLayout(ILayoutGenerator)
Provides an explicit override to this layout displayer to use the specified generator, instead of any default, when loading the layout for this display
Declaration
public void SetLayout(ILayoutGenerator generator)
Parameters
Type | Name | Description |
---|---|---|
ILayoutGenerator | generator | The generator to use when loading the layout for this displayer |
SetTabDisplayHandler(Func<LayoutTabSetting, Task>)
This controller handles enumerating all the views within a tab and correctly displaying the items for them, and does this in a multi-threaded way awaiting all views being displayed at once
However some client applications (such as single threaded console app) can use this to override the display of a tab and enumerate the view displays themselves
Declaration
public void SetTabDisplayHandler(Func<LayoutTabSetting, Task> tabDisplay)
Parameters
Type | Name | Description |
---|---|---|
System.Func<LayoutTabSetting, System.Threading.Tasks.Task> | tabDisplay | A function that enumerates displaying all the views on the specified tab to the user |
TrackItem(INotifyPropertyChanged)
Adds the specified item to the list of items that are being tracked for changes by this layout displayer. Any changes notify each registered listener via AddTrackedItemListener(TrackedItemChange)
Declaration
public void TrackItem(INotifyPropertyChanged item)
Parameters
Type | Name | Description |
---|---|---|
System.ComponentModel.INotifyPropertyChanged | item | The item to track changes for |
UpdateLayout()
Forces the layout displayer to update layout configuration of every tab in the displayer (because it has been modified by the user) to the LayoutDescriptor representing this layout stored in Layout
This provides an accurate model representing the current layout designed in the ui on the client application that can be recreated through a serialized LayoutDescriptor
Declaration
public void UpdateLayout()
UpdateSubViews(IModelView)
Informs the displayer that the specified view has had its SelectedItemForSubViews change, and thus all child views for this one should be updated accordingly
Declaration
public Task UpdateSubViews(IModelView view)
Parameters
Type | Name | Description |
---|---|---|
IModelView | view | The view that has had its SelectedItemForSubViews change, and needs all dependant sub-views to be updated |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task indicating the completion of the operation |
ValidateUI()
Validates the ui for the currently selected tab within the layout. Calls ValidateUI() on every view in the selected tab
Declaration
public void ValidateUI()
Events
TabChange
An event indicating that the currently selected tab in this layout has been changed by the user or the system
Declaration
public event LayoutTabChangedEvent TabChange
Event Type
Type | Description |
---|---|
LayoutTabChangedEvent |
ViewItemChange
An event indicating that a view has changed the output item (SelectedItemForSubViews) that other sub-views maybe dependant on
Declaration
public event LayoutSubViewItemChangedEvent ViewItemChange
Event Type
Type | Description |
---|---|
LayoutSubViewItemChangedEvent |