I tried to prevent user closing dgn file if a certain task hasn't been finished using C#.
Is there an event handler on file closing and some parameter can be set so that the closing action can be canceled?
Gang
Your options will vary based on how you choose to implement a solution and whether your C# code is in-process (MDL Addin), or out-of-process (limited mostly to MicroStation VBA's COM methods).
HTH,Bob
Thanks Bob.
It's in-process. I didn't find the exact place for handling the closing event. Would you please provide more information about it? Your help are appreciated.
Best,
Hi Gang,
Unknown said:I didn't find the exact place for handling the closing event.
In you addin inherited from Addin class a delegate NewDesignFileEventHandler exists, so in e.g. Run method use:
this.NewDesignFileEvent += UDialog_NewDesignFileEvent;
and the method should be like this:
void UDialog_NewDesignFileEvent(Bentley.MicroStation.AddIn sender, Bentley.MicroStation.AddIn.NewDesignFileEventArgs eventArgs){ if (eventArgs.WhenCode == NewDesignFileEventArgs.When.BeforeDesignFileClose) { // do what you need here }}
The problem is you can use this code to monitor that the file will be closed but there is no a way (I am not aware about any) how to close the running closing process from the method. Maybe somebody else know how to do it.
But in general existing NET API (which is VBA/COM API) is not the good tool for such close integration with MicroStation and as Robert wrote, C MDL API or C++ MicroStationAPI provide more options.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Thanks Jan.
I am using it to monitor it, but didn't find a way to stop it.