容器脚本情形
- Last UpdatedSep 24, 2024
- 1 minute read
以下情形阐明在容器脚本内部使用“显示/隐藏图形”脚本函数:您希望在关闭已显示图形时自动显示图形。这需要在 OnHide 预定义脚本内部针对一个图形创建 ShowGraphic 脚本,然后针对另一个图形创建 ShowGraphic 脚本。
要执行容器脚本情形,请执行以下操作:
-
创建称为“symbol01”的图形(例如,泵),另一个称为“symbol02”。
-
在“工业图形编辑器”画布上将名为“关闭”的按钮添加到 symbol01,并将动作脚本添加到该按钮:
HideSelf;
-
在“工业图形编辑器”画布上的 symbol02 中添加名为“显示泵”的按钮,并添加动作脚本以显示符号,如以下脚本示例中所示:
Dim graphicInfo as aaGraphic.GraphicInfo;
graphicInfo.Identity = "showpump_script001";
graphicInfo.GraphicName = "symbol01";
graphicInfo.WindowType = aaGraphic.WindowType.Modeless;
graphicInfo.WindowRelativePosition = aaGraphic.WindowRelativePosition.Window;
graphicInfo.WindowLocation = aaGraphic.WindowLocation.Bottom;
ShowGraphic( graphicInfo);
-
在 symbol01 中添加 OnHide 脚本。在脚本编辑器中,为第二个图形 symbol02 添加 ShowGraphic 函数,如以下脚本示例中所示:
Dim graphicInfo as aaGraphic.GraphicInfo;
graphicInfo.Identity = "showpump_script001";
graphicInfo.GraphicName = "symbol02";
graphicInfo.WindowType = aaGraphic.WindowType.Modeless;
graphicInfo.WindowRelativePosition = aaGraphic.WindowRelativePosition.Window;
graphicInfo.WindowLocation = aaGraphic.WindowLocation.Bottom;
ShowGraphic( graphicInfo);
第二个图形的 ShowGraphic 现在已在预定义(容器)脚本的内部配置。
-
转到运行时并打开包含“显示泵”按钮的窗口。
-
单击“显示泵”按钮。Symbol01 将显示。
-
在 symbol01 上单击“关闭”按钮。Symbol02 现在在 symbol01 的位置显示。
-
在此情形中,您在预定义脚本内部配置和演示 ShowGraphic 脚本,并使用该脚本在关闭第一个图形时自动显示另一个。
通过扩展,您可以相同方式配置更多图形,从而在运行时访问一系列图形,但只有一个按钮占据显示屏。您可以相同方式使用其它容器脚本(例如,OnShow 和 WhileShowing)和命名脚本。