Detecting DesignMode in PDS

Posted by tbergman on 12-Oct-2016 11:38

When working with .Net forms and user controls, many times there are initialization methods that fire from a load or other  event or are called by the constructor. In some cases it is undesirable to have these actions occurring when loading a class into the visual designer.

.Net controls have a DesignMode property that can be evaluated but it is not reliable as it only seems to be correct when the control is at most, a child of the class loaded in the design canvas, not a grandchild or further down the chain. This means that this detection won't be correct when a form contains a user control that contains a user control etc. DesignMode is a protected property so looping up through the parents won't work either.

I've come up with my own method but it seems like there should be something better. My method is to set a static property in a class when _idestartup.p runs. This property can then be read by any of the controls being loaded at design time and the behavior can be altered accordingly.

Is there a better way?

All Replies

Posted by Peter Judge on 12-Oct-2016 11:54
Posted by Matt Baker on 12-Oct-2016 12:34

 
Correction, OEM allows you to specify the user/password you want OEM to use for authentication.
 
OEM doesn’t allow you to change the password file setup for the /oemanager web application for the tomcat /manager application. OEM doesn’t know what auth system that is being used. This is dependent on the spring security context setup in the web application itself.
 
 

Posted by tbergman on 12-Oct-2016 13:52

Hi Peter,
 
Thanks for this.
 
I had abandoned the idea of using LicenseManager.UsageMode as it didn’t seem to work properly. After further testing, it does appear to work properly if, and only if, the evaluation is done inside the constructor. In the bit of code I’m using for testing, it properly shows DesignTime when in the constructor, but it shows Runtime when in the Load event of the control.
 
So I could set a variable in the constructor and then evaluate it wherever needed. Still not exactly ideal.
 

Posted by Mike Fechner on 12-Oct-2016 14:31

There does not seem to be a better way. We have implemented it this way using a property called DesignTime assigned from the components constructor.

This thread is closed