维宏LOGO
搜索结果

    显示/隐藏目录

    UI行为库

    Phoenix UI行为库提供了界面启动机制、界面的行为和转换器等支持。

    所属组件: Weihong.Phoenix.UI.Controls.dll

    命名空间: xmlns:ui="http://weihong.phoenix.ui.interactions"

    本文描述了这些行为的功能和使用方法,主要包括:

    • CallLuaFunctionAction 调用lua函数行为
    • CallMainLuaFunctionAction 调用lua函数行为
    • DependecyPropertyBehavior 通过事件Binding和绑定源的值
    • DragMoveBehavior 移动窗口行为
    • DynamicBindingForUIBehavior 绑定lua中变量行为
    • DynamicBindingBehavior 动态绑定行为
    • EventCallLuaFunctionBehavior 事件调用Lua函数行为
    • EventCallMainLuaFunctionBehavior 事件调用Lua函数行为
    • FormPresentBehavior 绑定WinForms控件行为
    • FMenu 菜单项
    • GlobalHotKeyBehavior 全局快捷键行为
    • HotKeyToEventBehavior 快捷键触发事件行为
    • HotKeyMulitiParameterBehavior 9个参数的快捷键行为
    • HotKeyBehavior 快捷键行为
    • ManualButtonServiceBehavior 手动按钮
    • SelectorFocusBehavior 列表控件定位焦点行为
    • SHotKeyBehavior 支持SFkey快捷键行为
    • SetPhoenixBehavior 寻址赋值行为
    • SetPropertyBehavior 事件触发设置属性值
    • ShowMessageBoxBehavior 调用MessageBox对话框行为
    • ShowDialogBehavior 调用对话框行为
    • UpDownKeyToSelectorForObjectFocusBehavior 上下键对列表类控件定焦点行为
    • WindowCanClosingBehavior 判断窗体是否可以关闭行为
    • Phoenix 寻址标记扩展
    • PathBinding 路径标记扩展
    • Uri 路径标记
    • XPage
    • Converter 转换器
    • 对话框机制
    • UIOperator 界面操作机制

    CallLuaFunctionAction 调用lua函数行为

    CallLuaFunctionAction 调用 Lua 函数行为,需要配合触发器使用。

    接口

    接口名称 类型 接口描述
    Function String 获取或设置行为调用的函数名称。应该是UI虚拟机中的,此函数默认存在一个参数(自己)。
    FunctionParameter String 获取或设置行为传给函数的参数。

    点击按钮时调用函数

    <Button >
    	<i:Interaction.Triggers>  
    		<i:EventTrigger EventName="Click">
    			<ui:CallLuaFunctionAction Function="FunctionTable.F2" FunctionParameter="1"/> 
    		</i:EventTrigger>
    	</i:Interaction.Triggers>
    </Button>
    

    Checkbox 选中时调用函数示例代码

    <CheckBox>
    	<i:Interaction.Triggers>
    		<i:EventTrigger EventName="Checked">
    			<iu:CallLuaFunctionAction Function="FunctionTable.F3"  /> 
    		</i:EventTrigger>
    	</i:Interaction.Triggers>
    </CheckBox>
    

    CallMainLuaFunctionAction 调用lua函数行为

    CallMainLuaFunctionAction 调用 主虚拟机Lua 函数行为,需要配合触发器使用。

    接口

    接口名称 类型 接口描述
    Function String 获取或设置行为调用的函数名称。应该是UI虚拟机中的,此函数默认存在一个参数(自己)。
    FunctionParameter String 获取或设置行为传给函数的参数。

    点击按钮时调用函数

    <Button >
    	<i:Interaction.Triggers>  
    		<i:EventTrigger EventName="Click">
    			<ui:CallMainLuaFunctionAction Function="FunctionTable.F2" FunctionParameter="1"/> 
    		</i:EventTrigger>
    	</i:Interaction.Triggers>
    </Button>
    

    Checkbox 选中时调用函数

    <CheckBox>
    	<i:Interaction.Triggers>
    		<i:EventTrigger EventName="Checked">
    			<iu:CallMainLuaFunctionAction Function="FunctionTable.F3"  /> 
    		</i:EventTrigger>
    	</i:Interaction.Triggers>
    </CheckBox>
    

    DependecyPropertyBehavior 通过事件Binding和绑定源的值。

    DependecyPropertyBehavior是通过事件Binding和绑定源的值

    接口

    接口名称 类型 接口描述
    Binding Object 获取或设置行为绑定的属性。
    Property String 获取或设置行为修改的属性。
    UpdateEvent String 获取或设置行为的事件名称。

    示例代码

    <Button >
    	<i:Interaction.Behaviors>
    		<iu:DependecyPropertyBehavior Binding="{Binding Text,ElementName=TestTextBox}"
    			UpdateEvent="PasswordChanged"
    			Property="Password" />
    	</i:Interaction.Behaviors>
    </Button>
    

    DragMoveBehavior 移动窗口行为

    DragMoveBehavior是按下鼠标左键进行窗口拖动的行为。

    示例代码

    <Border >
    	<i:Interaction.Behaviors>
    		<ui:DragMoveBehavior/>
    	</i:Interaction.Behaviors>
    </Border>
    

    DynamicBindingForUIBehavior 绑定lua中变量行为

    DynamicBindingForUIBehavior是支持绑定lua表中变量行为。

    接口

    接口名称 类型 接口描述
    UpdateInterval Uint? 获取或设置行为定时刷新属性值的时间间隔,单位是ms。
    Property String 获取或设置行为需绑定控件的属性名称。
    Path String 获取或设置行为需绑定变量的lua表路径,若此值不存在则返回null。
    Mode BindingMode 获取或设置行为指示绑定的数据方向. 可选值有:
    OneTime 当应用程序启动或数据上下文更改时,更新绑定目标。
    OneWayToSource 当目标属性更改时更新源属性。
    OneWay 当绑定源(源)更改时,更新绑定目标(目标)属性。
    TwoWay 寻址值发生改变自动更新绑定的组件属性,当绑定的属性值改变时更新寻址值.(Phoenix当使用twoway时,需添加UpdateInterval 和UpdateSourceEvent)。
    Default 使用绑定目标的默认 System.Windows.Data.Binding.Mode 值。每个依赖项属性的默认值都不同。一般情况下,用户可编辑控件属性默认为双向绑定,而多数其他属性默认为单向绑定。
    UpdateSourceEvent String 获取或设置行为指定更新寻址值的事件。
    UpdateTargetEvent String 获取或设置行为指定更新控件属性的事件。
    Converter IValueConverter 获取或设置行为要使用的转换器。
    ConverterParameter Object 获取或设置行为传递给转换器的参数。
    StringFormat String 获取或设置行为显示的字符串格式。
    TargetNullValue Object 获取或设置行为当绑定的寻址为null时,控件属性的值。

    示例代码:

    <TextBox >
    	<i:Interaction.Behaviors>
    		<ui:DynamicBindingForUIBehavior Property="Text" Path="property.Text" Mode="TwoWay" UpdateSourceEvent="TextChanged" UpdateInterval="300" StringFormat="当前值是:{0}" />
    	</i:Interaction.Behaviors>
    </TextBox>
    

    DynamicBindingBehavior 动态绑定行为

    DynamicBindingBehavior是支持寻址与控件属性进行关联(绑定)的行为。包括以下使用场景:

    • 只读:只将寻址的值更新到控件属性上,且实时更新数据(比如:坐标)
    • 只读:只将寻址的值更新到控件属性上,且不是实时更新,在特定事件时机时更新
    • 只写:寻址的值只通过控件来设置
    • 读写:既通过控件来修改,又通过脚本修改寻址的值。
    • 显示格式化 (StringFormat)
    • 使用转换器

    接口

    接口名称 类型 接口描述
    UpdateInterval Uint? 获取或设置行为定时刷新属性值的时间间隔。此间隔值为100的倍数,单位是ms。
    Property String 获取或设置行为需绑定控件的属性名称。
    Path String 获取或设置行为需绑定寻址的路径。
    Mode BindingMode 获取或设置行为指示绑定的数据方向。 可选值有:
    OneTime 当应用程序启动或数据上下文更改时,更新绑定目标。
    OneWayToSource 当目标属性更改时更新源属性。
    OneWay 当绑定源(源)更改时,更新绑定目标(目标)属性。
    TwoWay 寻址值发生改变自动更新绑定的组件属性,当绑定的属性值改变时更新寻址值.(Phoenix当使用twoway时,需添加UpdateInterval 和UpdateSourceEvent)。
    Default 使用绑定目标的默认 System.Windows.Data.Binding.Mode 值。每个依赖项属性的默认值都不同。一般情况下,用户可编辑控件属性默认为双向绑定,而多数其他属性默认为单向绑定。
    UpdateSourceEvent String 获取或设置行为指定更新寻址值的事件。
    UpdateTargetEvent String 获取或设置行为指定更新控件属性的事件。
    Converter IValueConverter 获取或设置要使用的转换器。
    ConverterParameter Object 获取或设置行为传递给转换器的参数。
    StringFormat String 获取或设置行为设定显示的字符串格式。
    TargetNullValue Object 获取或设置行为当绑定的寻址为null时,控件属性的值。

    只读:只将寻址的值更新到控件属性上,且实时更新数据(比如:坐标)

    <TextBlock >
    	<i:Interaction.Behaviors>
    		<ui:DynamicBindingBehavior Path="Phoenix.G.Channels[0].Auto.File.Name"
    			UpdateInterval = "100"  
    			Property="Text" />
    	</i:Interaction.Behaviors>
    </TextBlock>
    

    只读:只将寻址的值更新到控件属性上,且不是实时更新,在特定事件时机时更新

    <TextBlock >
    	<i:Interaction.Behaviors>
    		<ui:DynamicBindingBehavior Path="Phoenix.G.Channels[0].Auto.File.Name"
    			UpdateTargetEvent="MouseUp" 
    			Property="Text" />
    	</i:Interaction.Behaviors>
    </TextBlock>
    

    只写:寻址的值只通过控件来设置

    <TextBox >
    	<i:Interaction.Behaviors>
    		<ui:DynamicBindingBehavior Path="Phoenix.G.Channels[0].Auto.File.Name"
    			UpdateSourceEvent="TextChanged" 
    			Property="Text" />
    	</i:Interaction.Behaviors>
    </TextBox>
    

    读写:既通过控件来修改,又通过脚本修改寻址的值。

    <TextBox >
    	<i:Interaction.Behaviors>
    		<ui:DynamicBindingBehavior Path="Phoenix.G.Channels[0].Auto.File.Name"
    			UpdateInterval = "200" 
    			UpdateSourceEvent="TextChanged"
    			Mode = "TwoWay"
    			Property="Text" />
    	</i:Interaction.Behaviors>
    </TextBox>
    

    显示格式化 (StringFormat)

    StringFormat 只对string类型生效,所以只对 TextBlock和TextBox的text属性生效。

    添加单位

    <TextBlock >
    	<i:Interaction.Behaviors>
    		<ui:DynamicBindingBehavior Path="Phoenix.G.Channels[0].Auto.File.Name"
    			UpdateInterval = "100" 
    			StringFormat="{}{0} ms" 
    			Property="Text" />
    	</i:Interaction.Behaviors>
    </TextBlock>
    

    添加前缀

    <TextBlock >
    	<i:Interaction.Behaviors>
    		<ui:DynamicBindingBehavior Path="Phoenix.G.Channels[0].Auto.File.Name"
    			UpdateInterval = "100"
    			StringFormat="文件名:{0}" 
    			Property="Text" />
    	</i:Interaction.Behaviors>
    </TextBlock>
    

    小数位格式化

    <TextBlock >
    	<i:Interaction.Behaviors>
    		<ui:DynamicBindingBehavior Path="Phoenix.G.Channels[0].Auto.File.Name"
    			UpdateInterval = "100"
    			StringFormat="{}{0:F3}" 
    			Property="Text" />
    	</i:Interaction.Behaviors>
    </TextBlock>
    <TextBlock >
    	<i:Interaction.Behaviors>
    		<ui:DynamicBindingBehavior Path="Phoenix.G.Channels[0].Auto.File.Name"
    			UpdateInterval = "100"
    			StringFormat="听说:{0:F3}" 
    			Property="Text" />
    	</i:Interaction.Behaviors>
    </TextBlock>
    

    添加日期

    <TextBlock >
    	<i:Interaction.Behaviors>
    		<ui:DynamicBindingBehavior Path="Phoenix.G.Channels[0].Auto.File.DateTime"
    			UpdateInterval = "100"
    			StringFormat="yyyy-MM-dd HH:mm:ss"
    			Property="Text" />
    	</i:Interaction.Behaviors>
    </TextBlock>
    

    使用转换器

    需要将数据运算操作结果反馈给数据,比如:速度类参数。

    示例代码:

    <UserControl.Resources>
    	<ui:SpeedConvert x:Key="SpeedConvert"/>
    </UserControl.Resources>
    <TextBlock >
    	<i:Interaction.Behaviors>
    		<ui:DynamicBindingBehavior Path="Phoenix.G.Channels[0].Auto.File.DateTime"
    			UpdateInterval = "100"
    			Converter="{StaticResource SpeedConvert}" 
    			Property="Text" />
    	</i:Interaction.Behaviors>
    </TextBlock>
    

    EventCallLuaFunctionBehavior 事件调用Lua函数行为

    EventCallLuaFunctionBehavior 该行为是通过事件调用Lua函数,最多可以传9个参数,参数要按照顺序传递。

    接口

    接口名称 类型 接口描述
    EventName String 获取或设置行为的事件名称。
    Function String 获取或设置行为调用Lua函数路径。
    Parameter0 Object 获取或设置行为的调用Lua的参数(首参数)。
    Parameter1 Object 获取或设置行为的调用Lua的参数1。
    Parameter2 Object 获取或设置行为的调用Lua的参数2。
    Parameter3 Object 获取或设置行为的调用Lua的参数3。
    Parameter4 Object 获取或设置行为的调用Lua的参数4。
    Parameter5 Object 获取或设置行为的调用Lua的参数5。
    Parameter6 Object 获取或设置行为的调用Lua的参数6。
    Parameter7 Object 获取或设置行为的调用Lua的参数7。
    FuParameter8 Object 获取或设置行为的调用Lua的参数8。

    事件调用无参数Lua函数:

    Lua函数内容:
    function EventCallLuaFunctionNoParameter()	
    	Phoenix.G.Channels[1].Auto.File.Name = "AAAA"
    end
    <Button >
    	<i:Interaction.Behaviors>
    		<ui:EventCallLuaFunctionBehavior Function="EventCallLuaFunctionNoParameter"  EventName="Click"/>
    	</i:Interaction.Behaviors>
    </Button>
    

    事件调用多参数Lua函数:(多参数要按照顺序进行传递)

    Lua函数内容:
    function EventCallLuaFunction(a,b)	
    	Phoenix.G.Channels[0].Auto.File.Name = a+b
    end
    <Button >
    	<i:Interaction.Behaviors>
    		<ui:EventCallLuaFunctionBehavior Function="EventCallLuaFunction" Parameter0="1" FunctionParameter1="3" EventName="Click"/>
    	</i:Interaction.Behaviors>
    </Button>
    

    Lua函数传递的参数是对象:

    <RadioButton >
    	<i:Interaction.Behaviors>
    		<ui:EventCallLuaFunctionBehavior EventName="Loaded" Function="RecoverParaDialog.rbtnLoaded" 
    			Parameter0="{Binding ElementName=rad}" Parameter1="7"/>
    	</i:Interaction.Behaviors>
    </RadioButton>
    

    EventCallMainLuaFunctionBehavior 事件调用Lua函数行为

    EventCallMainLuaFunctionBehavior 该行为是通过事件调用Lua函数,最多可以传9个参数,参数要按照顺序传递。

    接口

    接口名称 类型 接口描述
    EventName String 获取或设置行为的事件名称。
    Function String 获取或设置行为调用Lua函数路径。
    Parameter0 Object 获取或设置行为的调用Lua的参数(首参数)。
    Parameter1 Object 获取或设置行为的调用Lua的参数1。
    Parameter2 Object 获取或设置行为的调用Lua的参数2。
    Parameter3 Object 获取或设置行为的调用Lua的参数3。
    Parameter4 Object 获取或设置行为的调用Lua的参数4。
    Parameter5 Object 获取或设置行为的调用Lua的参数5。
    Parameter6 Object 获取或设置行为的调用Lua的参数6。
    Parameter7 Object 获取或设置行为的调用Lua的参数7。
    FuParameter8 Object 获取或设置行为的调用Lua的参数8。

    事件调用无参数Lua函数:

    Lua函数内容:
    function EventCallMainLuaFunctionNoParameter()	
    	Phoenix.G.Channels[1].Auto.File.Name = "AAAA"
    end
    <Button >
    	<i:Interaction.Behaviors>
    		<ui:EventCallMainLuaFunctionBehavior Function="EventCallMainLuaFunctionNoParameter"  EventName="Click"/>
    	</i:Interaction.Behaviors>
    </Button>
    

    事件调用多参数Lua函数:

    多参数要按照顺序进行传递。

    Lua函数内容:
    function EventCallMainLuaFunction(a,b)	
    	Phoenix.G.Channels[0].Auto.File.Name = a+b
    end
    <Button >
    	<i:Interaction.Behaviors>
    		<ui:EventCallMainLuaFunctionBehavior Function="EventCallMainLuaFunction" Parameter0="1" FunctionParameter1="3" EventName="Click"/>
    	</i:Interaction.Behaviors>
    </Button>
    

    Lua函数传递的参数是对象

    <RadioButton >
    	<i:Interaction.Behaviors>
    		<ui:EventCallMainLuaFunctionBehavior EventName="Loaded" Function="RecoverParaDialog.rbtnLoaded" 
    			Parameter0="{Binding ElementName=rad}" Parameter1="7"/>
    	</i:Interaction.Behaviors>
    </RadioButton>
    

    FormPresentBehavior 绑定WinForms控件行为

    FormPresentBehavior 该行为是用于在WPF中呈现WinForm控件,只能用于ContentControl控件。

    接口

    接口名称 类型 接口描述
    GPath String 获取或设置行为的源路径。

    代码示例

    <wfi:WindowsFormsHost >
    	<i:Interaction.Behaviors>
    		<ui:FormPresentBehavior GPath="Phoenix.G.ContentControl" />
    	</i:Interaction.Behaviors>
    </wfi:WindowsFormsHost>
    

    FMenu 菜单项

    FMenu是菜单控件,用来管理软件上整个菜单。支持界面切换;左右菜单导航。包含以下控件:

    • FItem 菜单项对象
    • FButton 菜单按钮

    接口:

    接口名称 类型 描述
    IsSingleMenu Bool 设置一个值,该值指示是否允许菜单切换。
    Count Int 获取或设置菜单中FButton的数量。
    CurrentPage XPage 获取当前激活界面。
    CurrentFItem FItem 获取当前激活菜单。
    GoBack Bool 设置一个值,该值指示是否返回上一级。
    GoNext Bool 设置一个值,该值指示是否进入下一级。
    OwnerWindow Window 获取或设置根窗口,为对话框提供宿主。

    函数:

    函数 含义 参数 返回值
    SetMenu 设置菜单 FItem fitem(菜单项对象,对应每个页面的F菜单) 无
    SetPage 设置菜单 XPage page(基础页面文件) 无
    SetPage 设置菜单 XPage page(基础页面文件)
    FItem fitem(菜单项对象,对应每个页面的F菜单)
    无

    FItem 菜单项对象

    FItem是菜单项对象,对应每个页面的F菜单;继承ScriptButtonItem。

    接口:

    接口名称 类型 描述
    FPage XPage 获取拥有的Xpage。
    Menu FMenu 获取所在的Menu。
    Items Dictionary<string, FItem> 获取子菜单元素。
    IsTag Bool 获取一个值,该值指示是否是菜单根节点。
    Owner FItem 获取或设置父级别菜单项。
    Key String 获取或设置实际的FItem的Name。
    Depth Int 获取子菜单深度。
    CurrentItems Dictionary<string, FItem> 获取当前深度的菜单列。
    CanLeft Bool 获取一个值,该值指示是否可以左导航。
    CanRight Bool 获取一个值,该值指示是否可以右导航。
    StateFunction Object 获取可配置按钮的状态函数。
    ActionFunction Object 获取可配置按钮的动作函数。
    Text String 获取可配置按钮的描述。
    Image String 获取可配置按钮的图片路径。
    HotKey String 获取可配置按钮的快捷键。
    IsInAction Bool 获取一个值,该值指示是否正在执行ActionFunction。
    IsDefault Bool 获取一个值,该值指示是否支持按回车键触发Click事件。
    IsCancel Bool 获取一个值,该值指示是否支持按ESC关闭所在对话框。
    State ScriptItemState 获取按钮的状态。

    函数:

    函数 含义 参数 返回值
    MoveToLeftItem 移动到左菜单(1. 左边F菜单优先,2. 父菜单其次,3. 约定以BF来指定页面) 无 FItem
    MoveToRightItem 移动到右菜单 无 FItem

    FButton 菜单按钮

    FButton是所在FMenu的菜单按钮;继承FButtonBase。

    接口:

    接口名称 类型 接口描述
    Menu FMenu 获取该菜单按钮的FMenu。
    FName String 获取或设置该菜单按钮的快捷键名称。
    FPage XPage 获取该菜单按钮的当前界面。
    ScriptItem ScriptButtonItem 获取或设置配置的内容。
    ScriptPath String 获取或设置配置表路径。
    State ScriptItemState 获取或设置按钮的状态。
    Image ImageSource 获取或设置按钮的图片资源。
    HotKey String 获取或设置按钮的快捷键名称。
    OwnerPage XPage 获取或设置按钮所在的XPage。

    ScriptButtonItem 可配置按钮的配置内容项接口

    接口名称 类型 接口描述
    StateFunction Object 获取可配置按钮的状态函数。
    ActionFunction Object 获取可配置按钮的动作函数。
    Text String 获取可配置按钮的描述。
    Image String 获取可配置按钮的图片路径。
    HotKey String 获取可配置按钮的快捷键。
    IsInAction Bool 获取一个值,该值指示是否正在执行ActionFunction。
    IsDefault Bool 获取一个值,该值指示是否支持按回车键触发Click事件。
    IsCancel Bool 获取一个值,该值指示是否支持按ESC关闭所在对话框。
    State ScriptItemState 获取按钮的状态。

    ScriptItemState F按钮状态说明:

    接口名称 描述
    ENABLED(0) 可用
    DISABLED(1) 不可用
    CHECKED(2) 选中
    CHECKEDANDDISABLED(3) 选中不可用

    代码示例:

    <ui:FMenu Count="8" />  --Count为菜单呈现FButton的数量。
    

    GlobalHotKeyBehavior 全局快捷键行为

    GlobalHotKeyBehavior是全局快捷键行为。

    接口

    接口名称 类型 接口描述
    Key String 获取或设置行为的快捷键。
    Function String 获取或设置行为的Lua函数名称。
    Trigger KeyEventType 获取或设置行为的事件触发方式。
    Parameter0 Object 获取或设置行为的Lua函数参数0。
    Parameter1 Object 获取或设置行为的Lua函数参数1。
    Parameter2 Object 获取或设置行为的Lua函数参数2。
    Parameter3 Object 获取或设置行为的Lua函数参数3。
    Parameter4 Object 获取或设置行为的Lua函数参数4。
    Parameter5 Object 获取或设置行为的Lua函数参数5。
    Parameter6 Object 获取或设置行为的Lua函数参数6。
    Parameter7 Object 获取或设置行为的Lua函数参数7。
    Parameter8 Object 获取或设置行为的Lua函数参数8。

    代码示例

    <Button>
    	<i:Interaction.Behaviors>
    		<iu:GlobalHotKeyBehavior Key="Control+A" Trigger="KeyUp" Function="ShowLockWindow"/>
    	</i:Interaction.Behaviors>
    </Button>
    

    HotKeyToEventBehavior 快捷键触发事件行为

    HotKeyToEventBehavior是支持通过快捷键调用事件,目前支持事件:

    • Click
    • Checked
    • Unchecked
    • PreviewMouseLeftButtonDown
    • PreviewMouseLeftButtonUp
    • PreviewMouseRightButtonDown
    • PreviewMouseRightButtonUp
    • MouseRightButtonDown
    • MouseRightButtonUp

    接口

    接口名称 类型 接口描述
    Key String 获取或设置行为的快捷键。支持单键和组合键(用+组合)。
    KeyDownEvent EventType 获取或设置行为的KeyDown调用的事件。
    KeyUpEvent EventType 获取或设置行为的KeyUp调用的事件。

    场景1: K按下时触发Button Click事件

    <Button >
    	<i:Interaction.Behaviors>
    		<ui:HotKeyToEventBehavior Key="K" KeyDownEvent="Click"/>
    	</i:Interaction.Behaviors>
    </Button>
    

    场景2: L按下时触发Button PreviewMouseLeftButtonDown事件,L弹起时触发PreviewMouseLeftButtonUp事件

    <Button >
    	<i:Interaction.Behaviors>
    		<ui:HotKeyToEventBehavior Key="L" KeyDownEvent="PreviewMouseLeftButtonDown" KeyUpEvent="PreviewMouseLeftButtonUp"/>
    	</i:Interaction.Behaviors>
    </Button>
    

    HotKeyMulitiParameterBehavior 9个参数的快捷键行为

    HotKeyMulitiParameterBehavior 该行为是通过键盘操作快速实现某些功能,可以传多个参数,最多九个。

    接口

    接口名称 类型 接口描述
    Key String 获取或设置行为的快捷键。
    Trigger KeyEventType(枚举) 获取或设置行为的事件触发方式。
    Function String 获取或设置行为的调用Lua函数的名称。
    Parameter0 Object 获取或设置行为的调用Lua函数的参数0。
    Parameter1 Object 获取或设置行为的调用Lua函数的参数1。
    Parameter2 Object 获取或设置行为的调用Lua函数的参数2。
    Parameter3 Object 获取或设置行为的调用Lua函数的参数3。
    Parameter4 Object 获取或设置行为的调用Lua函数的参数4。
    Parameter5 Object 获取或设置行为的调用Lua函数的参数5。
    Parameter6 Object 获取或设置行为的调用Lua函数的参数6。
    Parameter7 Object 获取或设置行为的调用Lua函数的参数7。
    Parameter8 Object 获取或设置行为的调用Lua函数的参数8。

    代码示例

    <Button >
    	<i:Interaction.Behaviors>
    		<ui:HotKeyMulitiParameterBehavior Key="Shift+Alt+F3" Trigger="KeyDown" Function="TestFunction" Parameter0="2"  Parameter1="3"/>
    	</i:Interaction.Behaviors>
    </Button>
    

    注意: 两个控件不能定义相同的快捷键,否则无效。

    HotKeyBehavior 快捷键行为

    HotKeyBehavior 该行为是通过键盘操作快速实现某些功能。

    接口

    接口名称 类型 接口描述
    Key String 获取或设置行为的快捷键。
    Trigger KeyEventType(枚举) 获取或设置行为的事件触发方式。
    Function String 获取或设置行为的调用Lua函数的名称。
    FunctionParameter Object 获取或设置行为的设置传给函数的参数。

    不指定Lua函数时:

    <Button >
    	<i:Interaction.Behaviors>
    		<ui:HotKeyBehavior Key="F2" Trigger="KeyDown" />
    	</i:Interaction.Behaviors>
    </Button>
    

    需要指定Lua函数时:

    <Button >
    	<i:Interaction.Behaviors>
    		<ui:HotKeyBehavior Key="F1" Trigger="KeyDown" Function="TestFunction" FunctionParameter="2"/> 
    	</i:Interaction.Behaviors>
    </Button>
    

    注意: 两个控件不能定义相同的快捷键,否则无效。

    ManualButtonServiceBehavior 手动按钮

    ManualButtonServiceBehavior是提供手动按钮的行为支持。

    接口

    接口名称 类型 接口描述
    Key String 获取或设置行为的快捷键。
    StartFunction String 获取或设置行为启动手动连续的lua函数(虚拟机路径)。函数需要返回值。
    StopFunction String 获取或设置行为停止手动连续的lua函数(虚拟机路径)。函数需要返回值。
    StartParameter0 Object 获取或设置行为的Start函数参数0。
    StartParameter1 Object 获取或设置行为的Start函数参数1。
    StartParameter2 Object 获取或设置行为的Start函数参数2。
    StopParameter0 Object 获取或设置行为的Stop函数参数0。
    StopParameter1 Object 获取或设置行为的Stop函数参数1。
    StopParameter2 Object 获取或设置行为的Stop函数参数2。

    代码示例

    function ManualStart(o,e)	
    -- 启动手动的逻辑
    end 
    function ManualStop(o,e)
    -- 停止手动的逻辑
    end
    
    <Button >
    	<i:Interaction.Behaviors>
    		<ui:ManualButtonServiceBehavior Key="NumPad6" StartFunction="ManualStart" StopFunction="ManualStop" StartParameter0="0" StartParameter1="P" StopParameter0="0"/>
    	</i:Interaction.Behaviors>
    </Button>
    

    SelectorFocusBehavior 列表控件定位焦点行为

    SelectorFocusBehavior该行为是通过选择器控件获取焦点行为来解决列表控件在页面切换后的定位问题。

    代码示例

    <ListView Name="lw">
    	<i:Interaction.Behaviors>
    		<ui:SelectorFocusBehavior/>
    	</i:Interaction.Behaviors>
    	<ListView.View>
    		<GridView>
    			<GridViewColumn Header="test1" DisplayMemberBinding="{Binding Name}" Width="80"/>
    			<GridViewColumn Header="test2" DisplayMemberBinding="{Binding Age}" Width="100"/>
    		</GridView>
    	</ListView.View>
    </ListView>
    

    SHotKeyBehavior 支持SFkey快捷键行为

    SHotKeyBehavior 该行为是通过SF键盘操作快速实现某些功能。 行为继承HotKeyBehavior。

    接口

    继承HotKeyBehavior的接口

    接口名称 类型 接口描述
    Key String 获取或设置行为的快捷键。
    Trigger KeyEventType(枚举) 获取或设置行为的事件触发方式。
    Function String 获取或设置行为的调用Lua函数的名称。
    FunctionParameter Object 获取或设置行为的设置传给函数的参数。
    CanEffectToSubTable Bool 获取或设置一个值,该值指示是否点ShotKey按钮时切换到子界面。

    不指定Lua函数时:

    <Button >
    	<i:Interaction.Behaviors>
    		<ui:SHotKeyBehavior Key="F2" Trigger="KeyDown" />
    	</i:Interaction.Behaviors>
    </Button>
    

    需要指定Lua函数时:

    <Button >
    	<i:Interaction.Behaviors>
    		<ui:SHotKeyBehavior Key="F1" Trigger="KeyDown" Function="TestFunction" FunctionParameter="2"/> 
    	</i:Interaction.Behaviors>
    </Button>
    

    SetPhoenixBehavior 寻址赋值行为

    SetPhoenixBehavior是给Phoenix寻址赋值的行为。

    接口

    接口名称 类型 接口描述
    Path String 获取或设置寻址路径。
    Value Object 获取或设置寻址的值。
    EventName String 获取或设置指定事件的名称。
    AutoReverse Bool 获取或设置是否自动取反。

    G寻址:

    <Button >
    	<i:Interaction.Behaviors>
    		<ui:SetPhoenixBehavior Path="Phoenix.G.Channels[0].Auto.File.Name" Value="Goname" EventName="Click" />
    	</i:Interaction.Behaviors>
    </Button>
    

    绑定Value:

    <TextBox >
    	<i:Interaction.Behaviors>
    		<ui:SetPhoenixBehavior Path="Phoenix.G.Channels[0].Auto.File.Name" Value="{Binding Text,ElementName=textBox1}" EventName="TextChanged" />
    	</i:Interaction.Behaviors>
    </TextBox>
    

    SetPropertyBehavior 事件触发设置属性值

    SetPropertyBehavior是控件属性赋值的行为。

    接口

    接口名称 类型 接口描述
    Target DependencyObject 获取或设置目标对象。不配置或者配置不存在的控件时,默认修改自身属性的值。
    Property String 获取或设置需要更新值的属性 。
    Value Object 获取或设置设置的值。
    UpdateEvent String 获取或设置更新事件。

    代码示例

    <Button >
    	<i:Interaction.Behaviors>
    		<ui:SetPropertyBehavior Target="{Binding ElementName=lblTest, Mode=OneWay}" Property="Height" Value="30" UpdateEvent="Click"/>
    	</i:Interaction.Behaviors>
    </Button>
    

    注意: 当Target不配置或者配置不存在的控件时,默认为修改自身属性的值。

    ShowMessageBoxBehavior 调用MessageBox对话框行为

    ShowMessageBoxBehavior 该行为是实现调用提示信息对话框。

    接口

    接口名称 类型 接口描述
    EventName String 获取或设置事件名称。
    DialogTitle String 获取或设置对话框标题。
    Message String 获取或设置messagebox消息。
    OKButtonText String 获取或设置确定按钮文本。

    代码示例

    <Button >
    	<i:Interaction.Behaviors>
    		<ui:ShowMessageBoxBehavior EventName="Click" Message="开发" OKButtonText="OK" />
    	</i:Interaction.Behaviors>
    </Button>
    

    ShowDialogBehavior 调用对话框行为

    ShowDialogBehavior 该行为是实现调用无返回值对话框。

    接口

    接口名称 类型 接口描述
    EventName String 获取或设置事件名称。
    DialogTitle String 获取或设置对话框标题。
    XPagePath String 获取或设置对话框页面路径。
    Parameter Object 获取或设置对话框传递的参数。
    IsSingle Bool 获取或设置是否是单独的。

    代码示例

    <Button >
    	<i:Interaction.Behaviors>
    		<ui:ShowDialogBehavior XPagePath="{ui:PathBinding Pages/UserControl1.xaml}" EventName="Click" />
    	</i:Interaction.Behaviors>
    </Button>
    

    UpDownKeyToSelectorForObjectFocusBehavior 上下键对列表类控件定焦点行为

    UpDownKeyToSelectorForObjectFocusBehavior 该行为是通过上下键对列表类的控件定焦点的行为。

    接口

    接口名称 类型 接口描述
    GetFocusObject UIElement 获取或设置焦点对象。

    代码示例

    <ListBox >
    	<i:Interaction.Behaviors>
    		<ui:UpDownKeyToSelectorForObjectFocusBehavior GetFocusObject="{Binding ElementName=textbox1}" />
    	</i:Interaction.Behaviors>
    	<ListBoxItem>正常</ListBoxItem>
    	<ListBoxItem>2</ListBoxItem>
    	<ListBoxItem>2</ListBoxItem>
    	<ListBoxItem>2</ListBoxItem>
    </ListBox>
    

    WindowCanClosingBehavior 判断窗体是否可以关闭行为

    WindowCanClosingBehavior是支持关闭窗体时判断是否允许关闭,支持配置关闭软件前调用lua函数。

    接口

    接口名称 类型 接口描述
    Function String 获取或设置界面虚拟机中函数路径。函数需要返回值

    代码示例

    <Button >
    	<i:Interaction.Behaviors>
    		<ui:WindowCanClosingBehavior Function="Scripts.Closing"/>
    	</i:Interaction.Behaviors>
    <Button >
    

    Phoenix 寻址标记扩展

    Phoenix是支持寻址的绑定的标记扩展。

    接口

    接口名称 类型 接口描述
    Path String 获取或设置寻址路径。

    代码示例

    <TextBlock Text="{ui:Phoenix Phoenix.G.Calibration.Type}" />
    

    PathBinding 路径标记扩展

    PathBinding是Phoenix为使用外部资源提供的标记扩展,主要功能是结合路径。

    接口

    接口名称 类型 接口描述
    Path String 获取或设置行为的指定路径。可以是相对路径(相对UIDir的路径),也可以指定基于软件的绝对路径($(Phoenix寻址)/Pages/...)。

    场景1:UIDir中Resources\a.png。

    <Image Source="{ui:PathBinding Resources\a.png}"/>
    <Image Source="{ui:PathBinding $(Phoenix.G.Setting.UIDir)\Resources\a.png}"/>
    

    场景2: Addins目录下的Resources\a.png。

    <Image Source="{ui:PathBinding $(Phoenix.G.Setting.AddInsDir)\Resources\a.png}"/>
    

    Uri 路径标记

    Uri 支持界面路径扩展。

    接口

    接口名称 类型 接口描述
    Value String 获取或设置路径。支持相对(UIDir)路径,也支持绝对值($(Phoenix...))路径。

    绝对路径

    <ResourceDictionary.MergedDictionaries>
    	<ResourceDictionary Source="{ui:Uri $(Phoenix.G.Setting.UIDir)Styles\\Style-Black\\Styles.xaml}"/>
    </ResourceDictionary.MergedDictionaries>
    

    相对路径

    <ResourceDictionary.MergedDictionaries>
    	<ResourceDictionary Source="{ui:Uri Styles\\Style-Black\\Styles.xaml}"/>
    </ResourceDictionary.MergedDictionaries>
    

    XPage

    XPage是基础页面文件加载显示的界面。

    XPage配合FMenu使用时,菜单子项的配置包含:

    • State:状态控制。具体包括:
      • ENABLED
      • DISABLED
      • CHECKED
      • CHECKEDANDDISABLED
    • Text:菜单子项呈现的内容。
    • HotKey:菜单子项的快捷键。
    • Image:菜单子项显示的图片。
    • Action:菜单子项的行为函数。
    • IsDefault:菜单子项是否支持Enter键生效。
    • IsCancel:菜单子项是否支持ESC键生效。

    接口:

    接口名称 类型 描述
    IsShow Bool 获取或设置一个值,该值指示是否显示界面。
    IsPublic Bool 获取或设置一个值,该值指示是否将此xpage公开化。即保存到ui寻址中。
    Elements Dynamic 获取动态寻址成员的源对象。
    IsBuild Bool 获取或设置一个值,该值指示是否已绑定。
    Menu String 获取或设置页面挂接的菜单名字。
    Path String 获取或设置页面挂接的菜单路径。

    函数:

    函数 含义 参数 返回值
    Build 数据界面绑定 无 无
    Close 关闭界面 无 无
    Focus 尝试将焦点定位到此控件 无 无
    Show 显示此页面 无 无
    GetElementEnumerable 获取所有元素的枚举对象 无 IEnumerable<KeyValuePair<string, object>>(所有元素的枚举对象)
    FindName 根据名称获取控件 string key(控件名称) object(根据控件名称找到的控件)

    XPage在PC机上使用

    <ui:XPage Path="Pages\\Page.xaml"/>
    

    XPage在一体机上使用

    <ui:XPage Menu="Menu_Page" Path="Pages\\Page.xaml"/>  -- XPage界面
    
    --Lua表说明
    Page = {
    
    	-- 返回上级的箭头
    	Item_BF = {
    		Text="",
    
    		Action = function()
    			...
    		end 
    	};
    
    	Item_DisplayNo = {
    		Text = LS("UI.DisplayNo", "显示数量"),
            Image = "\\Resources\\1.png "
    		Action = function()
    			...
    		end 
    	};
    
    	Item_DisplayNo = {
    		Text = LS("UI.AllClear", "全部清除"),
    
    		Action = function(o)   ---- o为FButton对象本身
    			   ...
    		end 
    	};
    };
    
    Menu_Page = {
    	BF = Page.Item_BF,
    	F1 = Page.Item_DisplayNo,
    };
    

    Converter 转换器

    Converter支持在xaml下绑定,进行类型转换。包括以下类型:

    • BoolConverter bool类型的值转换器
    • BackPowerCalculationConvert 反幂转换器
    • ColorParameterConverter 颜色转换器
    • DoubleToStringConverter double类型占位格式化转换器
    • DoubleConverter double类型转器
    • DoubleFormatConvert double格式化转换器
    • EnumConverter 枚举类型转换器
    • FileNameConvert 路径转换文件名转换器
    • IntConverter 整型转换器
    • MathConverter 算术计算表达式转换器
    • PulseConvert 脉冲转换器
    • PercentConvert 把小数转换成百分数的分数转换器
    • SpeedConvert 速度转换器
    • UI.Round 按位四舍五入

    BoolConverter bool类型的值转换器

    <TextBlock Text="{Binding FilePath,Converter={StaticResource BoolConverter}}"/> 
    

    BackPowerCalculationConvert 反幂转换器

    <UserControl.Resources> 
    	<ui:BackPowerCalculationConvert x:Key="BackPowerCalculationConvert"/>
    </UserControl.Resources>
    <TextBlock Text="{Binding value ,Converter={StaticResource BackPowerCalculationConvert},ConverterParameter=2}"/> 
    

    ColorParameterConverter 颜色转换器

    <TextBlock Text="{Binding FilePath,Converter={StaticResource ColorParameterConverter}}"/> 
    

    DoubleToStringConverter double类型占位格式化转换器

    <TextBlock Text="{Binding FilePath,Converter={StaticResource DoubleToStringConverter}}"/> 
    

    DoubleConverter double类型转器

    <TextBlock Text="{Binding FilePath,Converter={StaticResource DoubleConverter}}"/> 
    

    DoubleFormatConvert double格式化转换器

    <TextBlock Text="{Binding value,Converter={StaticResource DoubleFormatConvert},ConverterParameter={}{0:C}}"/>
    

    EnumConverter 枚举类型转换器

    <TextBlock Text="{Binding FilePath,Converter={StaticResource EnumConverter}}"/> 
    

    FileNameConvert 路径转换文件名转换器

    <TextBlock Text="{Binding FilePath,Converter={StaticResource FileNameConvert}}"/> 
    

    IntConverter 整型转换器

    <TextBlock Text="{Binding FilePath,Converter={StaticResource IntConverter}}"/> 
    

    MathConverter 算术计算表达式转换器

    <Button >
    	<i:Interaction.Behaviors>
    		<ui:DynamicBindingBehavior Path="Phoenix.G.Test.TProperty" Converter="{StaticResource MathConverter}" ConverterParameter="(4-5+9)*$VALUE +12-9*(6-(9-7*(2+8)))"/>
    	</i:Interaction.Behaviors>
    </Button>
    

    PulseConvert 脉冲转换器

    <TextBlock Text="{Binding FilePath,Converter={StaticResource PulseConvert}}"/> 
    

    PercentConvert 把小数转换成百分数的分数转换器

    <TextBlock Text="{Binding FilePath,Converter={StaticResource PercentConvert}}"/> 
    

    SpeedConvert 速度转换器

    <TextBlock Text="{Binding FilePath,Converter={StaticResource SpeedConvert}}"/> 
    

    UI.Round 按位四舍五入

    local value = UI.Round(3.1415926, 3)	// Result : value = 3.142
    

    对话框机制

    目前支持对话框有普通对话框、带FButton对话框、Messaebox格式对话框。对话框内部不允许使用XPage页面。

    接口

    函数 含义 参数 返回值
    Input.ShowOK 弹出带确定按钮的提示信息对话框 string messageBoxText(内容)
    string caption (标题)
    string okButtonText(确定按钮的显示文本)
    string iconString (显示图标,有效值有:None,Error 错误图标,Hand 属性图标,Stop 停止图标,Question 问号图标,Exclamation 感叹号图标,Warning 警告图标,Information 消息图标,Asterisk 星号图标)
    “OK”
    Input.ShowOKCancel 弹出带确定和取消按钮的提示信息对话框 string messageBoxText(内容)
    string caption (标题)
    string okButtonText(确定按钮的显示文本)
    string cancelButtonText (取消按钮的显示文本)
    string iconString (显示图标,有效值有:None,Error 错误图标,Hand 属性图标,Stop 停止图标,Question 问号图标,Exclamation 感叹号图标,Warning 警告图标,Information 消息图标,Asterisk 星号图标)
    点击确定按钮:"OK"
    点击取消按钮或点击关闭按钮:“Cancel”
    Input.ShowYesNo 弹出带是和否按钮的提示信息对话框 string messageBoxText(内容)
    string caption (标题)
    string yesButtonText(是按钮的显示文本)
    string noButtonText (否按钮的显示文本)
    string iconString (显示图标,有效值有:None,Error 错误图标,Hand 属性图标,Stop 停止图标,Question 问号图标,Exclamation 感叹号图标,Warning 警告图标,Information 消息图标,Asterisk 星号图标)
    点击是按钮:"Yes"
    点击否按钮或关闭按钮:“No”
    Input.ShowYesNoCancel 弹出带是和否按钮的提示信息对话框 string messageBoxText(内容)
    string caption (标题)
    string yesButtonText(是按钮的显示文本)
    string noButtonText (否按钮的显示文本)
    string cancelButtonText (取消按钮的显示文本)
    string iconString (显示图标,有效值有:None,Error 错误图标,Hand 属性图标,Stop 停止图标,Question 问号图标,Exclamation 感叹号图标,Warning 警告图标,Information 消息图标,Asterisk 星号图标)
    点击是按钮:"Yes"
    点击否按钮:“No”
    点击取消按钮或关闭按钮:“Cancel”
    Input.ShowDialog 弹出普通对话框 string title(标题)
    string page (页面路径)
    object para (参数)
    string(对话框关闭返回的结果)
    默认值 None;
    有效值有:None,Yes,No,Cancel,Ok;
    此值的结果是在关闭对话框时由配置人员给CloseDialogResult赋的有效值。
    Input.ShowWindow 弹出非模态普通对话框 string title(标题)
    string page (页面路径)
    object para (参数)
    无
    Input.ShowSingleDialog 弹出普通对话框,当前有对话框弹出就不会在弹出。 string title(标题)
    string page (页面路径)
    object para (参数)
    string(对话框关闭返回的结果)
    默认值 None;
    有效值有:None,Yes,No,Cancel,Ok;
    此值的结果是在关闭对话框时由配置人员给CloseDialogResult赋的有效值。
    Input.ShowFDialog 弹出带FButton的对话框 string title(标题)
    string page (页面路径)
    string menu (FMenu lua中路径)
    object para (参数)
    string(对话框关闭返回的结果)
    默认值 None;
    有效值有:None,Yes,No,Cancel,Ok;
    此值的结果是在关闭对话框时由配置人员给CloseDialogResult赋的有效值。
    Input.ShowSingleFDialog 弹出带FButton的对话框,当前有对话框弹出就不会弹出 string title(标题)
    string page (页面路径)
    string menu (FMenu lua中路径)
    object para (参数)
    string(对话框关闭返回的结果)
    默认值 None;
    有效值有:None,Yes,No,Cancel,Ok;
    此值的结果是在关闭对话框时由配置人员给CloseDialogResult赋的有效值。
    Input.GetDialog 获得对话框对象 FrameworkElement 对话框的控件对象 对话框对象
    Input.GetFDialog 获得带FButton的对话框对象 FrameworkElement 对话框的控件对象 对话框对象
    Input.FolderBrowserDialog 弹出选择文件夹对话框 string selectedpath(选择的目录路径)
    Input.OpenFileDialog 弹出选文件对话框 string iniDir(初始目录),string extension(筛选后缀 格式:"Word Documents|*.doc"
    "Office Files*.doc;*.xls;*.ppt"
    "Word Documents|*.doc|Excel Worksheets|*.xls")
    可以不传参数
    string selectedpath(选择的文件路径)
    Input.SaveFileDialog 弹出保存文件对话框,如果设置的文件名称没有后缀,默认添加.nc后缀 string iniDir(初始目录),string getFileName (默认文件名) 可以不传参数 string selectedpath(选择的文件路径)
    Input.CloseDialog 关闭当前激活的对话框 无 无
    Input.ShowLockWindow 弹出锁定对话框 string key (快捷键), int? interval (延时时间), string text (锁屏文本,可以不传参数) key,Interval,text值的结果是在弹出锁屏对话框时由配置人员赋的有效值。

    FDialog 自定义对话框

    FDialog是自定义的对话框;为对话框机制提供自定义对话框。

    接口:

    接口名称 类型 接口描述
    UserTitle String 获取或设置对话框的用户标题。
    Page XPage 获取或设置对话框的用户内容。
    CodeDialog IDialogContent 获取或设置对话框的弹窗内容。
    CloseDialogResult String 获取或设置关闭对话框的结果。(结果详情查看CDialogResult接口说明)
    Parameter Object 获取或设置对话框传入的参数。

    函数:

    函数 含义 参数 返回值
    OK 确定 无 无
    Cancel 取消 无 无

    CDialogResult接口说明:

    接口名称 描述
    None(0) 没有值
    Yes(1) 是
    No(2) 否
    Cancel(3) 取消
    OK(4) 确定

    Input.ShowDialog

    • 不传参数
    local result = Input.ShowDialog("NcStudio",
    								"Pages\\DialogBox\\RepeatLoadFileDialog.xaml",
    								nil)
    If result== "OK" then 
    	…
    end
    
    • 传参数
    local para =  po --po为在使用时你需要的内容,可以是字符串,数字,对象等…
    local result = Input.ShowDialog("NcStudio",
    								"Pages\\DialogBox\\RepeatLoadFileDialog.xaml",
    								para)
    --在对话框脚本中使用下述语句能获得传进来的参数
    local p =Input.FindDialog(o).Parameter 
    

    Input.ShowWindow

    • 不传参数
    Input.ShowWindow("NcStudio",
    				 "Pages\\DialogBox\\RepeatLoadFileDialog.xaml",
    				 nil)
    
    • 传参数
    local para =  po --po为在使用时你需要的内容,可以是字符串,数字,对象等…
    Input.ShowWindow("NcStudio",
    				 "Pages\\DialogBox\\RepeatLoadFileDialog.xaml",
    				 para)
    --在对话框脚本中使用下述语句能获得传进来的参数
    local p =Input.FindDialog(o).Parameter  
    

    Input.ShowFDialog

    • 不传参数
    local result = Input.ShowFDialog("NcStudio",
    								 "Pages\\DialogBox\\RepeatLoadFileDialog.xaml",
    								 "Menu_RepeatLoadFileDialog",
    								 nil)
    If result== "OK" then 
    	…
    end
    
    • 传参数
    local para =  po --po为在使用时你需要的内容,可以是字符串,数字,对象等…
    Input.ShowFDialog("NcStudio",
    				  "Pages\\DialogBox\\RepeatLoadFileDialog.xaml",
    				  "Menu_RepeatLoadFileDialog"
    				  para)
    --在对话框脚本中使用下述语句能获得传进来的参数
    local p =Input.FindDialog(o).Parameter 
    

    Input.ShowSingleDialog

    • 不传参数
    local result = Input.ShowSingleDialog("NcStudio",
    									  "Pages\\DialogBox\\RepeatLoadFileDialog.xaml",
    									  nil)
    If result== "OK" then 
    	…
    end
    
    • 传参数
    local para =  po --po为在使用时你需要的内容,可以是字符串,数字,对象等…
    local result = Input.ShowSingleDialog("NcStudio",
    									  "Pages\\DialogBox\\RepeatLoadFileDialog.xaml",
    									  para)
    If result== "OK" then 
    	…
    end
    

    Input.ShowSingleFDialog

    • 不传参数
    local result = Input.ShowSingleFDialog("NcStudio",
    									   "Pages\\DialogBox\\RepeatLoadFileDialog.xaml",
    									   "Menu_RepeatLoadFileDialog",
    									   nil)
    If result== "OK" then 
    	…
    end
    
    • 传参数
    local para =  po --po为在使用时你需要的内容,可以是字符串,数字,对象等…
    local result = Input.ShowSingleFDialog("NcStudio",
    									   "Pages\\DialogBox\\RepeatLoadFileDialog.xaml",
    									   "Menu_RepeatLoadFileDialog",
    									   para)
    If result== "OK" then 
    	…
    end
    

    Input.ShowOK

    local result Input.ShowOK('密码错误,请重新输入!','NcStudio','确定','Warning')
    if result == "OK" then
    	…
    end
    

    Input.ShowOKCancel

    local result Input.ShowOKCancel('密码错误,请重新输入!','NcStudio','确定','取消','Warning')
    if result == "OK" then
    	…
    elseif result == "Cancel" then
    end
    

    Input.ShowYesNo

    local result Input.ShowYesNo('密码错误,请重新输入!','NcStudio','是','否','Warning')
    if result == "Yes" then
    	…
    elseif result== "No" then
    	…
    end
    

    Input.ShowYesNoCancle

    local result Input.ShowYesNoCancle('密码错误,请重新输入!','NcStudio','是','否','取消','Warning')
    if result == "Yes" then
    	…
    elseif result== "No" then
    	…
    elseif result == "Cancel"
    	…
    end
    

    Input.GetDialog

    local result = Input.GetDialog(o) --o是页面中任意的控件对象
    if result~=nil then
    	…
    end
    

    Input.GetFDialog

    local result = Input.GetFDialog(o) --o是页面中任意的控件对象
    if result~=nil then
    	…
    end
    

    Input.FolderBrowserDialog

    local result = Input.FolderBrowserDialog()
    if result~=nil then
    	…
    end
    

    Input.OpenFileDialog

    local result = Input.OpenFileDialog()
    if result~=nil then
    	…
    end
    
    local result = Input.OpenFileDialog(“D:\\NcFiles”,"nc文件|*.nc")
    if result~=nil then
    	…
    end
    
    local result = Input.OpenFileDialog(“D:\\NcFiles”)
    if result~=nil then
    	…
    end
    

    Input.SaveFileDialog

    local result = Input.SaveFileDialog()
    if result~=nil then
    	…
    end
    
    local result = Input.SaveFileDialog(“D:\\NcFiles”)
    if result~=nil then
    	…
    end
    
    local result = Input.SaveFileDialog(“D:\\NcFiles”,"nc文件.nc")
    if result~=nil then
    	…
    end
    

    Input.CloseDialog

    Input.CloseDialog()
    

    Input.ShowLockWindow

    Input.ShowLockWindow("Control+A,Control+B",5,"请用Alt+F4解锁")
    end
    

    获取当前对话框

    Input.GetDialog(o)//o为对话框中的控件
    注:如果是ContextMenuItem对象,则需以下方式使用:
    Input.GetDialog(o.Parent.PlacementTarget)
    

    获取当前对话框中的Xpage

    local w = Input.GetDialog(o)
    if w ~= nil then
    	local xpage = w.Page
    end
    

    获取当前对话框中某个控件元素

    local w = Input.GetDialog(o)
    if w ~= nil then
    	local textbox = w.Page:FindName(“textbox1”)//textbox1为控件的Name
    end
    

    获得当前对话框的父级窗体

    local w = Input.GetDialog(o)
    if w ~= nil then
    	local parentWindow = w.Owner
    end
    

    获得当前对话框的父级窗体的父窗体

    local w = Input.GetDialog(o)
    if w ~= nil then
    	local grandfatherWindow = w.Owner.Owner//再以上层级以此类推继续.Owner
    end
    

    获得当前对话框的父级窗体中的Xpage

    local w = Input.GetDialog(o)
    if w ~= nil then
    	local parentWindow = w.Owner
    	local xpage = parentWindow.Page
    end
    

    获得当前对话框的父级窗体中的控件元素

    local w = Input.GetDialog(o)
    if w ~= nil then
    	local parentWindow = w.Owner
    	local textbox = parentWindow.Page:FindName("textbox1")//textbox1为控件的Name
    end
    

    获得当前对话框的父级窗体的父级窗体中的Xpage

    local w = Input.GetDialog(o)
    if w ~= nil then
    	local grandfatherWindow = w.Owner.Owner//再以上层级以此类推继续.Owner
    	local xpage = grandfatherWindow.Page
    end
    

    获得当前对话框的父级窗体的父级窗体中的控件元素

    local w = Input.GetDialog(o)
    if w ~= nil then
    	local grandfatherWindow = w.Owner.Owner//再以上层级以此类推继续.Owner
    	local textbox = grandfatherWindow.Page:FindName("textbox1")//textbox1为控件的Name
    end	
    

    UIOperator 界面操作机制

    接口

    函数 含义 参数 返回值
    UI.GetOwnerPage 获取所在Xpage页面 FrameworkElement element(对象) 获取对象所在的Xpage
    UI.GetOwnerWindow 获取所在的Window FrameworkElement element(对象) 获取对象所在的Window
    UI.FindXPage 根据xpage名字获取当前页面下的xpage对象 FrameworkElement element(对象)
    string pagename(xpage名字)
    根据xpage名字获取的当前页面的xpage对象
    UI.GE lua中判断数值x是否大于等于数值y double x(数值1)
    double y(数值2)
    true:相等;false 不相等。
    UI.LE lua中判断数值x是否小于等于数值y double x(数值1)
    double y(数值2)
    true: 相等;false 不相等。
    UI.EQ lua中判断两个数值是否相等  double x(数值1)
    double y(数值2)
    true:相等;false 不相等。
    UI.Less lua中判断数值x是否小于数值y double x(数值1)
    double y(数值2)
    true:相等;false 不相等。
    UI.Great lua中判断数值x是否大于数值y double x(数值1)
    double y(数值2)
    true:相等;false 不相等。
    UI.Round lua中按位对数值进行四舍五入 double num(需四舍五入的数值)
    int idp(位数)
    按位四舍五入后的数值。

    UI.GetOwnerPage

    local page = UI.GetOwnerPage(o)
    if page ~= nil then
    	local dl = page:FindName("lvwParameter")  //获取所在Xpage中的lvwParameter名称的控件对象。
        ...
    end
    

    UI.GetOwnerWindow

    local window = UI.GetOwnerWindow(o)
    if window ~= nil then
    	local dl = window.Page  //获取所在window窗体的Xpage对象。
        ...
    end
    

    UI.FindXPage

    local xpage = UI.FindXPage(o,page)
    if xpage ~= nil then
    	local dl = xpage:FindName("lvwParameter")  //先根据Xpage的名字获取该Xpage对象,再获取Xpage中的lvwParameter对象。
        ...
    end
    

    UI.GE

    local isGE =  UI.GE(3,2)
    if isGE == true then
        ...
    end    
    

    UI.LE

    local isLE =  UI.LE(3,2)
    if isLE == true then
        ...
    end    
    

    UI.EQ

    local isEQ =  UI.EQ(3,2)
    if isEQ == true then
        ...
    end 
    

    UI.Less

    local isLess =  UI.Less(3,2)
    if isLess == true then
        ...
    end 
    

    UI.Great

    local isGreat =  UI.Great(3,2)
    if isGreat == true then
        ...
    end 
    

    UI.Round

    local isRound =  UI.Round(3,2)
    if isRound == true then
       ...
    end 
    
    本文内容
    回到顶端 Shanghai Weihong Electronic Technology Co., Ltd.