Altova StyleVision 2025 Enterprise Edition

In the code snippets below, the methods StartStyleVision_Click and ShutdownStyleVision_Click are those assigned to buttons in the AutomateStyleVision example that, respectively, start up and shut down the application. This example is located in the C# subfolder of the API Examples folder (see the file Form1.cs):

 

 

Windows 7, Windows 8, Windows 10, Windows 11

C:\Users\<username>\Documents\
Altova\StyleVision\2025\%APPNAME%>Examples

 

You can compile and run the project from within Visual Studio 2012/2013/2015/2017/2019/2022.

 

Starting StyleVision

The following code snippet from the AutomateStyleVision example shows how to start up the application.

 

       // Handler for the "Start StyleVision" button

       private void StartStyleVision_Click(object sender, EventArgs e)

       {

           if (StyleVision == null)

           {

               Cursor.Current = Cursors.WaitCursor;

 

               // If there is no StyleVision instance, create one and make it visible.

               StyleVision = new StyleVisionLib.Application();

               StyleVision.Visible = true;

 

               Cursor.Current = Cursors.Default;

           }

           else

           {

               // If an instance of StyleVision is already running, make sure it's visible

               if (!StyleVision.Visible)

                   StyleVision.Visible = true;

           }

       }

 

Shutting down StyleVision

The following code snippet from the AutomateStyleVision example shows how to shut down the application.

 

       // Handler for the "Shutdown StyleVision" button

       // Shut down the application instance by explicitly releasing the COM object.

       private void shutdownStyleVision_Click(object sender, EventArgs e)

       {

           if (StyleVision != null)

           {

               // Allow shut-down of StyleVision by releasing UI

               StyleVision.Visible = false;

 

               // Explicitly release the COM object

               try

               {

                   int i = System.Runtime.InteropServices.Marshal.ReleaseComObject(StyleVision);

                   while (System.Runtime.InteropServices.Marshal.ReleaseComObject(StyleVision) > 0) ;

               }

               finally

               {

                   // Disallow subsequent access to this object.

                   StyleVision = null;

               }

           }

       }

 

© 2018-2024 Altova GmbH