Altova UModel 2024

Los complementos deben implementar la interfaz IUModelPlugIn.

 

El código que aparece más abajo muestra una sencilla implementación de esta interfaz. Añade un elemento de menú y un separador al menú Edición de UModel. Al hacer clic en el elemento de menú aparecerá un cuadro de mensaje con el texto Hello, World!

 

Nota: como este ejemplo muestra un cuadro de mensaje, compruebe que su proyecto de C# también hace referencia a System.Windows.Forms.

 

using System;
using System.Collections.Generic;
using System.Text;
using UModelPlugInLib;
 
namespace HelloWorldPlugIn
{
  public class MyHelloWorldUModelPlugIn : IUModelPlugIn
  {
      #region IUModelPlugIn Members
 
      public string GetDescription()
      {
          return "HelloWorldPlugIn;HelloWorldPlugIn demonstrates a simple implementation of an IDE plug-in for UModel";
      }
 
      public string GetUIModifications()
      {
          return "<ConfigurationData>"                         +
                      "<Modifications>"                         +
                          // add "Hello World..." to Edit menu
                          "<Modification>"                     +
                              "<Action>Add</Action>"           +
                              "<UIElement type=\"MenuItem\">"   +
                                  "<ID>1</ID>"                 +
                                  "<Name>Hello world...</Name>" +
                                  "<Info>My hello world</Info>" +
                                  "<Place>0</Place>"           +
                                  "<MenuID>101</MenuID>"       +
                                  "<Parent>:Edit</Parent>"     +
                              "</UIElement>"                   +
                          "</Modification>"                     +
                      // add Separator to Edit menu
                          "<Modification>"                     +
                              "<Action>Add</Action>"           +
                              "<UIElement type=\"MenuItem\">"   +
                                  "<ID>0</ID>"                 +
                                  "<Place>1</Place>"           +
                                  "<MenuID>101</MenuID>"       +
                                  "<Parent>:Edit</Parent>"     +
                              "</UIElement>"                   +
                          "</Modification>"                     +
                      // finish modification description
                      "</Modifications>"                         +
                  "</ConfigurationData>";
      }
 
      public void OnInitialize(object pUModel)
      {
          // before processing DDE or batch commands
      }
 
      public void OnRunning(object pUModel)
      {
          // DDE or batch commands are processed; application is fully initialized
      }
 
      public void OnShutdown(object pUModel)
      {
          // application will shutdown; release all unused objects
      }
 
      public UModelUpdateAction OnUpdateCommand(int nID, object pUModel)
      {
          if (nID == 1)
              return UModelUpdateAction.UModelUpdateAction_Enable;
 
          return UModelUpdateAction.UModelUpdateAction_Disable;
      }
 
      public void OnCommand(int nID, object pUModel)
      {
          System.Windows.Forms.MessageBox.Show("Hello world!");
      }
 
      #endregion
  }
}

© 2017-2023 Altova GmbH