Search Results for

    Show / Hide Table of Contents

    Class ModelController

    The model controller is the client application controller used by all LemonEdge clients. This is responsible for creating the main application along with new windows, popups, messages, etc.

    If you are creating your own application you can utilise the LemonEdge controllers by calling Create(IModelViewer, Boolean) with an IModelViewer implementation.

    This is required as LemonEdge has multiple different clients running on windows, console, and web versions, they all implement the ui interfaces and connect through this model controller so lemonedge can just work with different ui platforms
    Inheritance
    System.Object
    ModelController
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: LemonEdge.Client.Core
    Assembly: ClientCore.dll
    Syntax
    public class ModelController

    Properties

    Instance

    The static instance of the model controller for this running application instance

    Declaration
    public static ModelController Instance { get; }
    Property Value
    Type Description
    ModelController

    PauseWaiterActions

    Only used by single thread application models, such as a command console

    Indicates that while the system is processing a task it should update the ui with a periodic indicator that it is processing.

    When this is false (default) it will not update the ui. For instance for the console application it will add a [.] every second it is still processing when this is true, and not for any other tasks
    Declaration
    public bool PauseWaiterActions { get; set; }
    Property Value
    Type Description
    System.Boolean

    Viewer

    The ModelViewer thie ModelController is using that is implemented by the client application to provide the specific UI components required by LemonEdge

    Declaration
    public IModelViewer Viewer { get; }
    Property Value
    Type Description
    IModelViewer

    Methods

    Create(IModelViewer, Boolean)

    Creates the static ModelController for this application instance. Should only be called once for each application.

    Declaration
    public static ModelController Create(IModelViewer viewer, bool withErrorHandling)
    Parameters
    Type Name Description
    IModelViewer viewer

    A client specific implementation of the IModelViewer by the application returning the client specific requested ui implementations

    System.Boolean withErrorHandling

    Indicates if the ModelController should handle any application domain level undhandled exceptions

    Returns
    Type Description
    ModelController

    The static single instance of the model controller for this application instance

    CreateLogin(IWindow)

    Creates the main login view and sets it up for lgging into the LemonEdge platform

    Declaration
    public Task<ILoginWindow> CreateLogin(IWindow owner = null)
    Parameters
    Type Name Description
    IWindow owner

    An optional owning window. When starting the application this is null, when switching login this will be the current main window

    Returns
    Type Description
    System.Threading.Tasks.Task<ILoginWindow>

    The created login window in the client application ui

    CreateMainForm(ISplashScreen, Boolean)

    Creates the main form application from the client ui, then checks the version of the application and service match, along with the license being valid, and then loads the local cache all while updating the splash screen to show the progress

    Declaration
    public Task<IMainform> CreateMainForm(ISplashScreen splashScreen, bool forceCacheLoadFromServer)
    Parameters
    Type Name Description
    ISplashScreen splashScreen

    The current splashscreen being showed while the main application loads

    System.Boolean forceCacheLoadFromServer

    If false indicates the local cache should be loaded, if one doesn't exist or this is false then it will always load the cache from the system and ignore any local copy

    Returns
    Type Description
    System.Threading.Tasks.Task<IMainform>

    The mainform created in the client application when the startup and cache have finished loading

    CreateSplashScreen()

    Creates the splash screen to be shown while initially loading the main application after logging in sucessfully

    Declaration
    public ISplashScreen CreateSplashScreen()
    Returns
    Type Description
    ISplashScreen

    The created splashscreen in the client application ui

    CreateWindow<T>(IWindow)

    Creates the specified type of window in the client application ui that implements the specified interface

    Declaration
    public T CreateWindow<T>(IWindow owner)
        where T : IWindow
    Parameters
    Type Name Description
    IWindow owner

    An optional parent window for the created window

    Returns
    Type Description
    T

    The created window in the client application ui

    Type Parameters
    Name Description
    T

    The interface the window to be created by the client application must implement

    DisplayMessage(IWindow, MessageType, Exception)

    Displays the specified exception message to the user in the client application ui

    Declaration
    public Task<MessageResult> DisplayMessage(IWindow owner, MessageType type, Exception ex)
    Parameters
    Type Name Description
    IWindow owner

    The owning window that originates the message, ensuring this message is a child of it

    MessageType type

    The type of message to display

    System.Exception ex

    The exception to display the details of to the user

    Returns
    Type Description
    System.Threading.Tasks.Task<MessageResult>

    A task returning how the user dismissed the message box

    DisplayMessage(IWindow, MessageType, String, String, ImageType)

    Displays the specified message to the user in the client application ui

    Declaration
    public Task<MessageResult> DisplayMessage(IWindow owner, MessageType type, string title, string message, ImageType img)
    Parameters
    Type Name Description
    IWindow owner

    The owning window that originates this message

    MessageType type

    The type of message to display

    System.String title

    The title for the message

    System.String message

    The message itself to display to the user

    ImageType img

    The image to use with the message

    Returns
    Type Description
    System.Threading.Tasks.Task<MessageResult>

    A task returning how the user dismissed the message box

    DisplayParam(IModelLayoutCommon, String)

    Declaration
    public Task<(bool WindowExistsInUI, bool OkClicked, SerializedParam Result)> DisplayParam(IModelLayoutCommon host, string serializedInstance)
    Parameters
    Type Name Description
    IModelLayoutCommon host
    System.String serializedInstance
    Returns
    Type Description
    System.Threading.Tasks.Task<System.ValueTuple<System.Boolean, System.Boolean, SerializedParam>>

    DisplayParam(IModelLayoutCommon, Type, String)

    Displays a popup param viewer for the specified paramType (which must derive from SerializedParam)

    For every paramType you need a core ui implementation of ParamViewerController<T>, and for the client application itself to have a ui component implementing IParamViewer<T> to display the parameter appropriately for the controller.

    Your core ui code can then interact with the controller and not worry about the ui specific implementation in each client
    Declaration
    public Task<(bool WindowExistsInUI, bool OkClicked, SerializedParam Result)> DisplayParam(IModelLayoutCommon host, Type paramType, string serializedInstance = null)
    Parameters
    Type Name Description
    IModelLayoutCommon host

    The host this popup has as a parent

    System.Type paramType

    The type of SerializedParam the system should load the param viewer of

    System.String serializedInstance

    An optional serialized instance of the parameter. If null a default parameter for the specified type is created and used instead.

    Returns
    Type Description
    System.Threading.Tasks.Task<System.ValueTuple<System.Boolean, System.Boolean, SerializedParam>>

    A tuple holding 3 parts:

    WindowExistsInUI: Indicates if the specified popup form actually exists in the client UI. Some applications may not implement all user interface components - for instace ones that interact with excel are not available form the console application

    OkClicked: Indicates if the user clicked ok to close the popup

    Result: If ok was clicked then this holds the result from the popup window, otherwise it'll just hold the default value for this type as it should not be read if okclicked is false

    DisplayParam<TResult>(IModelLayoutCommon, TResult)

    Declaration
    public Task<(bool WindowExistsInUI, bool OkClicked, TResult Result)> DisplayParam<TResult>(IModelLayoutCommon host, TResult param)
        where TResult : SerializedParam
    Parameters
    Type Name Description
    IModelLayoutCommon host
    TResult param
    Returns
    Type Description
    System.Threading.Tasks.Task<System.ValueTuple<System.Boolean, System.Boolean, TResult>>
    Type Parameters
    Name Description
    TResult

    DisplayParam<TResult>(IModelLayoutCommon, String)

    Declaration
    public Task<(bool WindowExistsInUI, bool OkClicked, TResult Result)> DisplayParam<TResult>(IModelLayoutCommon host, string serializedInstance)
        where TResult : SerializedParam
    Parameters
    Type Name Description
    IModelLayoutCommon host
    System.String serializedInstance
    Returns
    Type Description
    System.Threading.Tasks.Task<System.ValueTuple<System.Boolean, System.Boolean, TResult>>
    Type Parameters
    Name Description
    TResult

    DisplayParamSingle(IModelLayoutCommon, Byte[])

    Displays a single popup param viewer for the specified serializedInstance (which must deserializes from SerializedParam)

    For the serialized type you need a core ui implementation of ParamSingleViewerController<T>

    Your core ui code can then interact with the controller and not worry about the ui specific implementation in each client

    The main difference over the DisplayParam(IModelLayoutCommon, Type, String) implementation is the single param viewers implements a similar control addition as the standard single view, so you can easily add controls to your parameter viewer without having to create ui components in the application yourself

    Declaration
    public Task<(bool WindowExistsInUI, bool OkClicked, SerializedParam Result)> DisplayParamSingle(IModelLayoutCommon host, byte[] serializedInstance)
    Parameters
    Type Name Description
    IModelLayoutCommon host

    The host this popup has as a parent

    System.Byte[] serializedInstance

    An optional serialized instance of the parameter. If null an error is thrown.

    Returns
    Type Description
    System.Threading.Tasks.Task<System.ValueTuple<System.Boolean, System.Boolean, SerializedParam>>

    A tuple holding 3 parts:

    WindowExistsInUI: Indicates if the specified popup form actually exists in the client UI. Some applications may not implement all user interface components - for instace ones that interact with excel are not available form the console application

    OkClicked: Indicates if the user clicked ok to close the popup

    Result: If ok was clicked then this holds the result from the popup window, otherwise it'll just hold the default value for this type as it should not be read if okclicked is false

    Remarks

    For instance this can be used for a parameter that has an associated ParamSingleViewerController<T> class like so:

    var (WindowExistsInUI, OkClicked, Result) = await Client.Core.ModelController.Instance.DisplayParamSingle(owner, param.ToSerializedBytes());

    DisplayParamSingle(IModelLayoutCommon, String)

    Displays a single popup param viewer for the specified serializedInstance (which must deserializes from SerializedParam)

    For the serialized type you need a core ui implementation of ParamSingleViewerController<T>

    Your core ui code can then interact with the controller and not worry about the ui specific implementation in each client

    The main difference over the DisplayParam(IModelLayoutCommon, Type, String) implementation is the single param viewers implements a similar control addition as the standard single view, so you can easily add controls to your parameter viewer without having to create ui components in the application yourself

    Declaration
    public Task<(bool WindowExistsInUI, bool OkClicked, SerializedParam Result)> DisplayParamSingle(IModelLayoutCommon host, string serializedInstance)
    Parameters
    Type Name Description
    IModelLayoutCommon host

    The host this popup has as a parent

    System.String serializedInstance

    An optional serialized instance of the parameter. If null an error is thrown.

    Returns
    Type Description
    System.Threading.Tasks.Task<System.ValueTuple<System.Boolean, System.Boolean, SerializedParam>>

    A tuple holding 3 parts:

    WindowExistsInUI: Indicates if the specified popup form actually exists in the client UI. Some applications may not implement all user interface components - for instace ones that interact with excel are not available form the console application

    OkClicked: Indicates if the user clicked ok to close the popup

    Result: If ok was clicked then this holds the result from the popup window, otherwise it'll just hold the default value for this type as it should not be read if okclicked is false

    Remarks

    For instance this can be used for a parameter that has an associated ParamSingleViewerController<T> class like so:

    var (WindowExistsInUI, OkClicked, Result) = await Client.Core.ModelController.Instance.DisplayParamSingle(owner, param.ToSerializedString());

    DisplayParamSingle(IModelLayoutCommon, Type, Byte[])

    Displays a single popup param viewer for the specified paramType (which must derive from SerializedParam)

    For every paramType you need a core ui implementation of ParamSingleViewerController<T>

    Your core ui code can then interact with the controller and not worry about the ui specific implementation in each client

    The main difference over the DisplayParam(IModelLayoutCommon, Type, String) implementation is the single param viewers implements a similar control addition as the standard single view, so you can easily add controls to your parameter viewer without having to create ui components in the application yourself

    Declaration
    public Task<(bool WindowExistsInUI, bool OkClicked, SerializedParam Result)> DisplayParamSingle(IModelLayoutCommon host, Type paramType, byte[] serializedInstance = null)
    Parameters
    Type Name Description
    IModelLayoutCommon host

    The host this popup has as a parent

    System.Type paramType

    The type of SerializedParam the system should load the param viewer of

    System.Byte[] serializedInstance

    An optional serialized instance of the parameter. If null a default parameter for the specified type is created and used instead.

    Returns
    Type Description
    System.Threading.Tasks.Task<System.ValueTuple<System.Boolean, System.Boolean, SerializedParam>>

    A tuple holding 3 parts:

    WindowExistsInUI: Indicates if the specified popup form actually exists in the client UI. Some applications may not implement all user interface components - for instace ones that interact with excel are not available form the console application

    OkClicked: Indicates if the user clicked ok to close the popup

    Result: If ok was clicked then this holds the result from the popup window, otherwise it'll just hold the default value for this type as it should not be read if okclicked is false

    Remarks

    For instance this can be used for a parameter that has an associated ParamSingleViewerController<T> class like so:

    var (WindowExistsInUI, OkClicked, Result) = await Client.Core.ModelController.Instance.DisplayParamSingle(owner, param.GetType(), param.ToSerializedString());

    DisplayParamSingle(IModelLayoutCommon, Type, String)

    Displays a single popup param viewer for the specified paramType (which must derive from SerializedParam)

    For every paramType you need a core ui implementation of ParamSingleViewerController<T>

    Your core ui code can then interact with the controller and not worry about the ui specific implementation in each client

    The main difference over the DisplayParam(IModelLayoutCommon, Type, String) implementation is the single param viewers implements a similar control addition as the standard single view, so you can easily add controls to your parameter viewer without having to create ui components in the application yourself

    Declaration
    public Task<(bool WindowExistsInUI, bool OkClicked, SerializedParam Result)> DisplayParamSingle(IModelLayoutCommon host, Type paramType, string serializedInstance = null)
    Parameters
    Type Name Description
    IModelLayoutCommon host

    The host this popup has as a parent

    System.Type paramType

    The type of SerializedParam the system should load the param viewer of

    System.String serializedInstance

    An optional serialized instance of the parameter. If null a default parameter for the specified type is created and used instead.

    Returns
    Type Description
    System.Threading.Tasks.Task<System.ValueTuple<System.Boolean, System.Boolean, SerializedParam>>

    A tuple holding 3 parts:

    WindowExistsInUI: Indicates if the specified popup form actually exists in the client UI. Some applications may not implement all user interface components - for instace ones that interact with excel are not available form the console application

    OkClicked: Indicates if the user clicked ok to close the popup

    Result: If ok was clicked then this holds the result from the popup window, otherwise it'll just hold the default value for this type as it should not be read if okclicked is false

    Remarks

    For instance this can be used for a parameter that has an associated ParamSingleViewerController<T> class like so:

    var (WindowExistsInUI, OkClicked, Result) = await Client.Core.ModelController.Instance.DisplayParamSingle(owner, param.GetType(), param.ToSerializedString());

    DisplayPopup<T, TResult>(IWindow, Func<T, Task>, Func<T, PopupWindowController<TResult>>)

    Declaration
    public Task<(bool WindowExistsInUI, bool OkClicked, TResult Result)> DisplayPopup<T, TResult>(IWindow owner, Func<T, Task> initWindow, Func<T, PopupWindowController<TResult>> createController)
        where T : IPopupWindow<TResult>
    Parameters
    Type Name Description
    IWindow owner
    System.Func<T, System.Threading.Tasks.Task> initWindow
    System.Func<T, PopupWindowController<TResult>> createController
    Returns
    Type Description
    System.Threading.Tasks.Task<System.ValueTuple<System.Boolean, System.Boolean, TResult>>
    Type Parameters
    Name Description
    T
    TResult

    Shutdown()

    Forces a shutdown of the entire client application

    Declaration
    public void Shutdown()

    Extension Methods

    MiscExtensions.SetIfNotEqual<T, P>(T, Expression<Func<T, P>>, P)
    ReflectionExtensions.ClearEventInvocations(Object, String)
    StringExtensions.ToCSVFormatString(Object, Type)
    SQLExtensions.ToSQLValue(Object, Boolean)
    In This Article
    Back to top © LemonTree Software Ltd. All rights reserved.