Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
50
AppStylistRuntime - Close Event?
posted

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?

Parents
  • 469350
    Offline posted

    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;
            }

     

Reply Children