Embedding dialogue box by custom coding

Issue #34 invalid
Former user created an issue

Hi, I would like to add an optimization function of the reservoir operation for the reservoir nodes in MODSIM. We can do it by writing the optimization algorithms in the custom coding. But I don't know how I can add the dialog box in the custom coding in MODSIM. If MODSIM allows us to add dialog boxes, it really help us to developing optimization model in MODSIM.

Comments (5)

  1. Bob Lounsbury

    I'm not completely sure I understand the intent of what you'd like to do. As you've seen, the custom code uses the Microsoft .NET Framework as does MODSIM itself, so anything you could do with .NET "could" be accomplished within the MODSIM custom code editor form. However, for larger tasks the custom code editor is cumbersome and nothing more than a very very simple text editor. If you want to show end users a dialog box where they could tweak your reservoir optimization function and run the model I would recommend that you use Visual Studio and reference the necessary MODSIM dll's within your Visual Studio project. The free community edition of Visual Studio is perfectly fine for this, https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx.

    You would just copy the code you've already written into a new visual studio project and add references within visual studio to A2CM.dll, libsim.dll, ModsimModel.dll, NetworkUtils.dll, and XYFile.dll. I generally copy these dll's to a folder with the visual studio project so that the project can be easily moved between machines.

    There is a bug in the latest version of MODSIM 8.4.4, where new References cannot be added to the custom code editor. That has been fixed and a new version of MODSIM will be coming out soon, version 8.4.5.

  2. Bob Lounsbury

    As my previous comment states, this is certainly possible with the existing custom code editor but a better solution would be to use Visual Studio to create a dialog box and run MODSIM.

  3. Former user Account Deleted

    Thanks for your reply. I have coded by using the Visual Studio for calling MODSIM model, so I know the technique. As you mentioned in the comments that "this is certainly possible with the existing custom code editor ", is it possible to let us know the simple example of the procedure?

  4. Bob Lounsbury

    Sorry, no, I don't have a simple example, mostly because it's not that simple and that is not the intent of the custom code editor. For a task like you've proposed Visual Studio is the way to go. Otherwise, you will need to manually write all the code that Visual Studio automatically writes for you when you create/design a form. So, yes, it's certainly possible to write all the code in the custom code editor, but we cannot recreate the Visual Studio experience within our simple custom code editor, that would be a huge task!

    You could possibly write all the code in Visual Studio into a single .cs file that does what you want and then you should be able to copy that .cs file and open it in the custom code editor and it should run. You would need to make sure to add the appropriate dll's like: System.Windows.Forms, etc.

  5. Log in to comment