Altova UModel 2024 Professional Edition

UModel IDE Plug-ins müssen die IUModelPlugIn Schnittstelle implementieren. Der nachstehenden Code zeigt eine einfache Implementierung dieser Schnittstelle. Es werden ein Menübefehl und eine (mit UModel verfügbare) Trennlinie zum Menü Bearbeiten hinzugefügt. Wenn Sie auf den Menüeintrag klicken, wird ein Meldungsfeld mit dem Text "Hello, World!" angezeigt.

 

Anmerkung: Da in diesem Beispiel ein Meldungsfeld angezeigt wird, stellen Sie sicher, dass System.Windows.Forms in Ihrem C#-Projekt referenziert wird. Klicken Sie dazu mit der rechten Maustaste im Solution Explorer auf References, wählen Sie Add Reference aus und navigieren Sie zur System.Windows.Forms-Assembly.

 

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