Create a NetLogic that fetches panels

This NetLogic fetches a panel from the Server project and loads it in the Client project.

Prerequisites

Set the default external code editor. See Set the default code editor.

To create a NetLogic that fetches panels
  1. In Project view, right-click MainWindow (type) and select New > Runtime NetLogic.
  2. Hover-over the NetLogic, select Edit, and enter PanelFetcher.
  3. Double-click the NetLogic.
    The external code editor opens.
  4. In the code editor, replace the existing code with the following code:
    #region Using directives
    using System;
    using UAManagedCore;
    using OpcUa = UAManagedCore.OpcUa;
    using FTOptix.HMIProject;
    using FTOptix.Retentivity;
    using FTOptix.NativeUI;
    using FTOptix.UI;
    using FTOptix.OPCUAClient;
    using FTOptix.Core;
    using FTOptix.CoreBase;
    using FTOptix.NetLogic;
    using FTOptix.UI;
    #endregion
    
    public class PanelFetcher : BaseNetLogic
    {
        public override void Start()
        {
            var importedPanel = Project.Current.Get("UI/Panels/Panel1");
            if (importedPanel == null)
            {
                Log.Error("Could not find remote panel");
                return;
            }
    
            var mainWindowPanelLoader = LogicObject.Owner.Get<FTOptix.UI.PanelLoader>("ClientPanelLoader");
    
          // Change panel to the imported remote panel.
            mainWindowPanelLoader.ChangePanel(importedPanel.NodeId, NodeId.Empty);
        }
    
        public override void Stop()
        {
            // Insert code to be executed when the user-defined logic is stopped
        }
    }
  5. Save the code.