Skip to main content
Definition: LIBS/DotNetUtils/Phoenix.ModelCenter.PlugIn/SModelCenterHost.cs (line 35) This class acts as a host between a plug-in and the ModelCenter desktop API. It provides common utilities and helpers as well as a simplified API that is focused on what is needed to to write a plug-in. The preferred way to use this is to make your plug-in extend AbstractModelCenterPlugIn, which will manage the lifetime of this object. To use it directly, create an instance in IComponentPlugIn.construct() and pass it the arguments from the function call. Do not keep around the original arguments to construct(). Lastly, be sure to call Dispose() on this object from IComponentPlugIn.onEnd() for component plug-ins and when your UI is closed for trade study plug-ins. ?> It is recommended that your plug-in extends AbsractModelCenterPlugIn, which handles creation and destruction of this class. Inherits from:
  • AbstractDisposable

Members

Private static attributes

Variable DATE_EPOCH_SECONDS

Definition: LIBS/DotNetUtils/Phoenix.ModelCenter.PlugIn/SModelCenterHost.cs (line 39)
Type: const string

Variable DATE_YEAR_MONTH_DAY

Definition: LIBS/DotNetUtils/Phoenix.ModelCenter.PlugIn/SModelCenterHost.cs (line 40)
Type: const string

Variable DATE_UTCG

Definition: LIBS/DotNetUtils/Phoenix.ModelCenter.PlugIn/SModelCenterHost.cs (line 41)
Type: const string

Private attributes

Variable mcVars

Definition: LIBS/DotNetUtils/Phoenix.ModelCenter.PlugIn/SModelCenterHost.cs (line 43)
Type: readonly Dictionary< string, IVariable >

Variable variables

Definition: LIBS/DotNetUtils/Phoenix.ModelCenter.PlugIn/SModelCenterHost.cs (line 44)
Type: readonly List< PHXVariable >

Variable _dataCollector

Definition: LIBS/DotNetUtils/Phoenix.ModelCenter.PlugIn/SModelCenterHost.cs (line 46)
Type: IDataCollector

Properties

Property ModelCenter

Definition: LIBS/DotNetUtils/Phoenix.ModelCenter.PlugIn/SModelCenterHost.cs (line 57)
Get the ModelCenter COM object. Using this allows your plug-in full access to the power of the IModelCenter API, but this should be used with caution as it may make your plug-in less distributable. When a functionality exists on this class and in the IModelCenter API, your plug-in should prefer the functions here. Return type: IModelCenter

Property DataCollector

Definition: LIBS/DotNetUtils/Phoenix.ModelCenter.PlugIn/SModelCenterHost.cs (line 64)
Get the DataCollector COM object. This function should not be used from a distributable component plug-in. Return type: IDataCollector

Property AddToModel

Definition: LIBS/DotNetUtils/Phoenix.ModelCenter.PlugIn/SModelCenterHost.cs (line 82)
Get the AddToModel COM object. Using this allows your plug-in full access to the power of the IModelCenter API, but this should be used with caution as it may make your plug-in less distributable. When a functionality exists on this class and in the IModelCenter API, your plug-in should prefer the functions here. Return type: IAddToModel

Property MyComponent

Definition: LIBS/DotNetUtils/Phoenix.ModelCenter.PlugIn/SModelCenterHost.cs (line 89)
Get my component, if any. Using this allows your plug-in full access to the power of the IModelCenter API, but this should be used with caution as it may make your plug-in less distributable. When a functionality exists on this class and in the IModelCenter API, your plug-in should prefer the functions here. Return type: IComponent

Property Log

Definition: LIBS/DotNetUtils/Phoenix.ModelCenter.PlugIn/SModelCenterHost.cs (line 94)
Get a logger that can be used to log information about what is happening in your plug-in. Return type: IPHXLogger

Property IsAddedToModel

Definition: LIBS/DotNetUtils/Phoenix.ModelCenter.PlugIn/SModelCenterHost.cs (line 248)
Gets a value indicating whether the component has already been added to the model. Return type: bool

Property ModelDirectory

Definition: LIBS/DotNetUtils/Phoenix.ModelCenter.PlugIn/SModelCenterHost.cs (line 286)
Get the directory of the current model. If no model is open it will raise an error.If the model has not yet been saved, it will return an empty string. Return type: string

Property RootName

Definition: LIBS/DotNetUtils/Phoenix.ModelCenter.PlugIn/SModelCenterHost.cs (line 346)
Get the name of my component. Return type: string

Property ModelCenterDirectory

Definition: LIBS/DotNetUtils/Phoenix.ModelCenter.PlugIn/SModelCenterHost.cs (line 354)
Get the ModelCenter install directory. It is not recommended that plug-ins use this value as this directory is generally write protected and the contents can change from version to version. Returns: The full path to the directory where ModelCenter is installed. Return type: string

Property NumCurrentVariables

Definition: LIBS/DotNetUtils/Phoenix.ModelCenter.PlugIn/SModelCenterHost.cs (line 525)
Get the number of variables. Return type: int

Property CurrentVariables

Definition: LIBS/DotNetUtils/Phoenix.ModelCenter.PlugIn/SModelCenterHost.cs (line 538)
Get or set a collection of the variables we’ve set/added (but perhaps not committed). On setting, the variables are cloned, and the changes are flushed through to ModelCenter. There are two ways to create variables - set them all at once by setting CurrentVariables, or set them individually with AddVariable then commit with CommitVariableChanges. Do not mix and match Return type: IEnumerable< PHXVariable >

Property ModelCenterWindowHandle

Definition: LIBS/DotNetUtils/Phoenix.ModelCenter.PlugIn/SModelCenterHost.cs (line 791)
Get the handle of the ModelCenter window. Return type: IntPtr

Property ModelCenterWindow

Definition: LIBS/DotNetUtils/Phoenix.ModelCenter.PlugIn/SModelCenterHost.cs (line 810)
Get the ModelCenter window (actually just a handle wrapped in a utility class, but can be used as a window in many cases). Return type: IWin32Window

Events

Event DataCollectorCreated

Definition: LIBS/DotNetUtils/Phoenix.ModelCenter.PlugIn/SModelCenterHost.cs (line 220)
Event generated when a new data collector is created. Type: DataCollectorCreatedEventHandler

Public functions

Function SModelCenterHost

Constructor. This object becomes responsible for the passed in objects. You should not store them or use them after passing them to this constructor. They can be retrieved by using the appropriate properties from this object. They will be disposed properly when this object is disposed. Parameters:
  • mc: The ModelCenter COM instance.
  • atm: The AddToModel COM instance.
Parameters:
  • IModelCenter mc
  • IAddToModel atm
Return type:

Function SModelCenterHost

Constructor. This object becomes responsible for the passed in objects. You should not store them or use them after passing them to this constructor. They can be retrieved by using the appropriate properties from this object. They will be disposed properly when this object is disposed. Parameters:
  • mc: The ModelCenter COM instance.
  • atm: The AddToModel COM instance.
  • dc: The DataCollector COM instance.
Parameters:
  • IModelCenter mc
  • IAddToModel atm
  • IDataCollector dc
Return type:

Function CreateNewDataCollector

Create a new data collector and stores it in the DataCollector property. Parameters:
  • analysisType: The type of trade study or analysis.
  • configuration: The configuration string.
Returns: The new data collector, which is also stored in the DataCollector property. Parameters:
  • string analysisType
  • string configuration
Return type: IDataCollector

Function GetAssociatedFiles

Get the list of associated files, if any. This is used to inform the host of files that are necessary for the operation of the Plug-In. For example, Excel Plug-In would put the excel file being refrenced in this list. In some distributed cases these files will be delivered with the component for execution on a remote host. Note that file locations and names may be changed on remote systems, but the order in which the files are returned will always match the order given to SetAssociatedFiles. Returns: Returns an enumerable of strings of the associated files. Return type: IEnumerable< string >

Function SetAssociatedFiles

Set the associated files for the component. This is used to inform the host of files that are necessary for the operation of the Plug-In. For example, Excel Plug-In would put the excel file being refrenced in this list. In some distributed cases these files will be delivered with the component for execution on a remote host. Note that file locations and names may be changed on remote systems, but the order in which the files are returned from GetAssociatedFiles will always match the order given here. Parameters:
  • files: The list of files.
Parameters:
  • params string[] files
Return type: void

Function SetAssociatedFiles

Se the associated files for the component. This is used to inform the host of files that are necessary for the operation of the Plug-In. For example, Excel Plug-In would put the excel file being refrenced in this list. In some distributed cases these files will be delivered with the component for execution on a remote host. Note that file locations and names may be changed on remote systems, but the order in which the files are returned from GetAssociatedFiles will always match the order Parameters:
  • files: The sequence of files.
Parameters:
  • ICollection< string > files
Return type: void

Function CheckOutLicenseFeature

Check out the specified license feature. The release date will be the release date of the ModelCenter doing the checking out. Parameters:
  • featureName: The name of the feature.
Returns: The feature. Parameters:
  • string featureName
Return type: IFeature

Function CheckOutLicenseFeature

Check out the specified license feature. Parameters:
  • featureName: The name of the feature.
  • releaseDate: The release date of the feature in yyyy.MMdd format.
Returns: The feature. Parameters:
  • string featureName
  • string releaseDate
Return type: IFeature

Function RefreshFromModelCenter

Read the variables from ModelCenter and cache locally. Return type: void

Function CommitVariableChanges

Commit any changes in the variable list to ModelCenter. This is a more convenient alternative to using IAddToModel.addInput and .addOutput. Return type: void

Function AddVariable

Add a new variable to the local list, which will not be committed. There are two ways to create variables - set them all at once by setting CurrentVariables, or set them individually with AddVariable then commit with CommitVariableChanges. Do not mix and match Parameters:
  • v: The variable
Parameters:
  • PHXVariable v
Return type: void

Function GetValue

Get the value of a variable in a formatted string format for display. Do not use this to pass the value to an external API as formatted strings often lose precision. If the variable was just created individually, you will need to commit changes, because the variable won’t exist yet in the model. Parameters:
  • name: The name of the variable.
Returns: The value of the variable. Parameters:
  • string name
Return type: string

Function GetRawValue

Get the unmodified value of a variable. No formatting is done other than converting to a string. If the variable was just created individually, you will need to commit changes, because the variable won’t exist yet in the model. This function will return the contents of file variables, base64 encoded if the file variable is binary. Parameters:
  • name: The name of the variable.
Returns: The value. Parameters:
  • string name
Return type: string

Function SetValue

Set the value of a variable. If the variable was just created individually, you will need to commit changes, because the variable won’t exist yet in the model. This will read formatted strings if the variable is double or integer. If the variable is a file variable, pass the filename as the value. Parameters:
  • v: The variable to set the value for.
  • value: The value to set.
Parameters:
  • PHXVariable v
  • string value
Return type: void

Function SetValue

Set a variable value. If the variable was just created individually, you will need to commit changes, because the variable won’t exist yet in the model. This will read formatted strings if the variable is double or integer. If the variable is a file variable, pass the filename as the value. Parameters:
  • name: The name of the variable.
  • value: The value to set.
Parameters:
  • string name
  • string value
Return type: void

Function GetHasChanged

Get whether the value of a variable has changed since the last time we reset the changed flag. If the variable was just created individually, you will need to commit changes, because the variable won’t exist yet in the model. Parameters:
  • name: The name of the variable.
  • reset: Whether the flag should be reset.
Returns: True if yes, false if no. Parameters:
  • string name
  • bool reset = false
Return type: bool

Function ResetHasChanged

Reset the changed flag on a variable. If the variable was just created individually, you will need to commit changes, because the variable won’t exist yet in the model. Parameters:
  • name: The name of the variable.
Parameters:
  • string name
Return type: void

Function BringWindowToTop

Bring a window to the top. Parameters:
  • hWnd: The window handle.
Returns: True on success, false on failure. Parameters:
  • IntPtr hWnd
Return type: bool

Function BringModelCenterToTop

Bring the ModelCenter window to the top and activate it. Return type: void

Function AddIconToModelCenter

Load an icon in ModelCenter. Uses a temporary file. Parameters:
  • icon: The icon to load.
Returns: A unique index to the icon which can be used later. Parameters:
  • Icon icon
Return type: short

Function SetGroupIcon

Set an icon for a group in ModelCenter. Parameters: Parameters:
  • string groupName
  • short iconID
Return type: void

Function CreatePlugInFrame

Create a plugin frame to hold a plugin window. Parameters:
  • name: The name of the plugin.
  • title: The window title.
  • showFavorites: Whether to show favorites.
  • plugin: The plugin object.
  • initialSize: The initial size of the frame.
  • minSize: The minimum size of the frame.
Returns: The window handle of the frame. Parameters:
  • string name
  • string title
  • bool showFavorites
  • IComponentPlugIn plugin
  • Size initialSize
  • Size minSize
Return type: IntPtr

Function ShowPlugInFrame

Use this after creating a frame to ensure that it is shown. Parameters:
  • hwnd: The frame to show.
Parameters:
  • IntPtr hwnd
Return type: void

Function ReleasePlugInFrame

Release the plug-in frame created by CreatePlugInFrame. Parameters:
  • hWnd: The frame window handle.
Parameters:
  • IntPtr hWnd
Return type: void

Private functions

Function init

Return type: void

Function releaseMCVars

Return type: void

Function RetrieveAllVariables

Retrieve variables from nested groups, recursively. Parameters:
  • prefix: The name prefix (previously-seen groups).
  • mcObject: The component or group to search.
Parameters:
  • string prefix
  • object mcObject
Return type: void

Function getVariableInternal

Parameters:
  • string name
Return type: IVariable

Function setValueInternal

Parameters:
  • IVariable var
  • PHXDataType type
  • string value
Return type: void

Function createPlugInFrame2

Parameters:
  • string name
  • string title
  • object plugin
  • bool showFavorites
  • Size initialSize
  • Size minSize
Return type: IntPtr

Function createPlugInFrame

Parameters:
  • string name
  • string title
  • object plugin
  • bool showFavorites
  • Size initialSize
Return type: IntPtr

Protected functions

Function Dispose

Dispose of the COM objects immediately to avoid having to wait for garbage collection. Parameters:
  • disposing: Whether we are in the disposing phase.
Parameters:
  • bool disposing
Return type: override void