V8i and C# InitApp examples ?

Hi,

I get a very minimal c# initapp working well. 

But .. I don't know how to open Microstation MainForm or to avoid Microstation exiting at the end of mi initapp....

Where can i find examples  or  documentation?

BTW, is there C# Microstation developing tutorials or articles?

Thanks to everybody,

Marco

My simple initapps follows:

 

namespace UstnInitApp

{

  [Bentley.MicroStation.AddInAttribute( ApplicationType = MdlApplicationType.InitApp, 

                                        KeyinTree = "Commands.xml",

                                        MdlTaskID = "UstnInitApp")]

  public sealed class UstnInitApp : Bentley.MicroStation.AddIn

  {

    static UstnInitApp m_App = null;


    private UstnInitApp(System.IntPtr mdlDesc)

      : base(mdlDesc) {

      m_App = this;

    }

    protected override int Run(System.String[] commandLine) {

      MessageBox.Show("Hello from inside Microstation", "Debug", MessageBoxButtons.OK, MessageBoxIcon.Information);

      return 0;

    }

  }

}

Parents
  • Unknown said:
    I don't know how to open Microstation MainForm or to avoid Microstation exiting at the end of mi initapp

    You need to open a DGN file. When used as an MS_INITAPPS, MicroStation remains active only as long as a DGN file is open. Typically, you would process a list of files, and close the last one, at which point MicroStation exits.

    Use mdlSystem_enterGraphics if you want to display any graphics (DGN or dialog boxes) to the user.

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

  • Thanks Jon,

    I got it (at last) as shown in the following code:

    namespace UstnInitApp

    {

     [Bentley.MicroStation.AddInAttribute( ApplicationType = MdlApplicationType.InitApp,

                                           KeyinTree = "Commands.xml",

                                           MdlTaskID = "UstnInitApp")]

     public sealed class UstnInitApp : Bentley.MicroStation.AddIn

     {

       static UstnInitApp m_App = null;

       private UstnInitApp(System.IntPtr mdlDesc)

         : base(mdlDesc) {

         m_App = this;

       }

       protected override int Run(System.String[] commandLine) {

           ApplicationObjectConnector app = new ApplicationObjectConnectorClass();

           app.Application.Visible = true;

           DesignFile dgn = app.Application.OpenDesignFile( @"C:\example.dgn",true,MsdV7Action.AskUser);

         MessageBox.Show("Hello from inside Microstation", "Debug", MessageBoxButtons.OK, MessageBoxIcon.Information);

         return 0;

       }

     }

    }

  • Uhm,

    there's a problem inside my example .... it starts two Microstation processes.

    I shouldn't use ApplicationObjectConnectorClass and  interop!

    Any idea on how to open a Microstation MainForm without using interop ?

    Thanks,

    Marco

  • AddIn is a DLL

    An AddIn should be built as a DLL, implying that MicroStation must be running in order to load the AddIn. That is, its code executes in MicroStation's address space.

    The following statement starts another instance of MicroStation …

    ApplicationObjectConnector app = new ApplicationObjectConnectorClass();

    But you know already that MicroStation is running.

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

Reply Children
No Data