Good morning,
I am utilizing the AppStylistRuntime control to expose for administrators / our QA lab to proactively find issues or fix the application styles; however I noticed that if they "Switch" the ISL within our application (so not through the Runtime, but through the provided abilities in the app) without closing the AppStylistRuntime they get a nasty unhandled error which requires an app restart to use the AppStylistRuntime again.
While I'm not particularly concerned with the error - it makes sense, as it has one style loaded and now we're switching - I need a way to prevent them from switching styles while using the runtime. I can disable the dropdown which allows them to change the style, but I cannot find a way to either check if the AppStylistRuntime is already open, or an event to catch when it is closing. I tried the dispose event, but it's not hitting the code I put into that method.
Any ideas?
Hi,
The AppStylistRunTime should not be crashing when you load another isl into memory. That seems like a bug to me. But I tried it out and I was unable to duplicate the exception.
Can you duplicate this in a small sample project and post it here so we can check it out?
To answer your question, the AppStylist run-time form is basically just a form Form like any other. So you can use the OwnedForms collection of your form to get a reference to the dialog and hook events on it.
The close button on this dialog just hides the window, it does not actually close it. So I recommend using the VisibleChanged event. So, for example, you could keep a flag that tells you whether the dialog is displayed like this:
private void ShowAppStylistRuntTime() { this.appStylistRuntime1.ShowRuntimeApplicationStylingEditor(this, "AppStylist Runtime"); this.OwnedForms[0].VisibleChanged += new EventHandler(Form1_VisibleChanged); this.isAppStylingRunTimeDisplayed = true; } void Form1_VisibleChanged(object sender, EventArgs e) { Form appstylistRunTimeForm = (Form)sender; appstylistRunTimeForm.VisibleChanged -= new EventHandler(Form1_VisibleChanged); this.isAppStylingRunTimeDisplayed = false; }
Thanks Mike! I will give that a try, and post a test app when possible. to note, why I think the error is occuring is because the way we have it set is that we have a list of ISL files, and when they select an ISL file it copies over a standard isl "Default.ISL". So switching an ISL is actually overwriting the ISL file "Default.ISL"
-Sean
Once the Isl file is loaded into memory, the StyleManager does not keep a reference back to the file on the hard drive. So replacing that file should not cause any problems.
I suppose there might be an issue if you load an isl file and then load a new isl file with the same name. I don't see why that should be an issue, but I haven't tried it, and it's possible that maybe there's a problem there.
If that is the case, then a possible solution might be to unload the current style library before loading the new one.
Try calling StyleManager.Reset(); immediately before StyleManager.Load() and see if that makes a difference.