创建用于获取面板的 NetLogic
此 NetLogic 用于从服务器项目获取面板并将其加载到客户端项目中。
先决条件
设置默认外部代码编辑器。请参见设置默认代码编辑器。
- 创建用于获取面板的 NetLogic
- 在项目视图中,右键单击MainWindow (type),然后选择 。
- 将光标悬停在 NetLogic 上,选择 并输入PanelFetcher。
- 双击 NetLogic。外部代码编辑器将打开。
- 在代码编辑器中,使用以下代码替换现有代码:#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 } }
- 保存代码。
提供反馈