当前位置:网站首页>视觉上位系统设计开发(halcon-winform)-2.全局变量设计
视觉上位系统设计开发(halcon-winform)-2.全局变量设计
2022-07-03 15:08:00 【11eleven】
系统中会有很多数据需要执行流转,以及触发或者存储发送, 这里引入自定义的全局变量来完成这种需求,首先对全局变量数据对象进行设计。
/// <summary>
/// 全局变量
/// </summary>
public class GlobalVariableModel
{
public VariableTypeEnum VariableType { set; get; }
public string VariableName { set; get; }
public object VariableValue { set; get; }
public string Remark { set; get; }
}
public enum VariableTypeEnum
{
String = 0,
Int = 1,
Float = 2,
Decimal = 3,
Short = 4,
Bool = 5
}
包含数据类型、变量名称、变量值、备注。全局变量直接挂载在方案下面。一个方案的变量包含多个,因此是个List集合。

变量会贯穿每个节点 都可以使用,从节点触发 到节点执行后,以及数据结果关联都会用得到。

维护的界面采用的是代码动态绘制panel 文本框 下拉框按钮等,自定义变量等等。代码如下
private VariableControlModel AddTriggerControl()
{
FlowLayoutPanel triggerPanel = new FlowLayoutPanel();
triggerPanel.BorderStyle = BorderStyle.FixedSingle;
triggerPanel.FlowDirection = FlowDirection.LeftToRight;
triggerPanel.Width = FlowPanelVariable.Width - 10;
triggerPanel.Height = 42;
Label variableLabel = new Label();
variableLabel.Text = "变量";
variableLabel.Height = triggerPanel.Height;
variableLabel.AutoSize = false;
variableLabel.Width = 50;
variableLabel.TextAlign = ContentAlignment.MiddleRight;
TextBox textBoxName = new TextBox();
textBoxName.Width = 80;
//类型
Label variableTypeLabel = new Label();
variableTypeLabel.Text = "类型";
variableTypeLabel.Height = triggerPanel.Height;
variableTypeLabel.AutoSize = false;
variableTypeLabel.Width = 50;
variableTypeLabel.TextAlign = ContentAlignment.MiddleRight;
ComboBox comboBox = new ComboBox();
comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
comboBox.ValueMember = "Value";
comboBox.DisplayMember = "Name";
comboBox.Items.AddRange(typeList.ToArray());// (typeList.MapToList<VariableTypeModel>().ToArray());
//comboBox.SelectedItem = item.Key;
Label variableValueLabel = new Label();
variableValueLabel.Text = "值";
variableValueLabel.Height = triggerPanel.Height;
variableValueLabel.TextAlign = ContentAlignment.MiddleRight;
variableValueLabel.AutoSize = false;
variableValueLabel.Width = 30;
TextBox textBox = new TextBox();
textBox.Width = 100;
Label variableRemarkLabel = new Label();
variableRemarkLabel.Text = "备注";
variableRemarkLabel.Height = triggerPanel.Height;
variableRemarkLabel.TextAlign = ContentAlignment.MiddleRight;
variableRemarkLabel.AutoSize = false;
variableRemarkLabel.Width = 50;
TextBox textBoxRemark = new TextBox();
textBoxRemark.Width = 250;
Button button = new Button();
button.Text = "移除";
button.Width = 50;
button.Height = 32;
button.Click += Button_Click; ;
//textBox.Text = item.Value;
var model = new VariableControlModel()
{
FlowLayoutPanel = triggerPanel,
VariableType = comboBox,
VariableValueBox = textBox,
VariableNameBox = textBoxName,
VariableRemarkBox = textBoxRemark,
};
VariableControlModels.Add(model);
triggerPanel.Controls.Add(variableLabel);
triggerPanel.Controls.Add(textBoxName);
triggerPanel.Controls.Add(variableTypeLabel);
triggerPanel.Controls.Add(comboBox);
triggerPanel.Controls.Add(variableValueLabel);
triggerPanel.Controls.Add(textBox);
triggerPanel.Controls.Add(variableRemarkLabel);
triggerPanel.Controls.Add(textBoxRemark);
triggerPanel.Controls.Add(button);
FlowPanelVariable.Controls.Add(triggerPanel);
return model;
}容器采用的是FlowPanel ,可以自动流式布局 控件添加到panel会自动往后追加,比较方便。
好了以上就是全局变量的设计思路。
边栏推荐
- [Yu Yue education] scientific computing and MATLAB language reference materials of Central South University
- cpu飙升排查方法
- Chapter 14 class part 1
- [set theory] inclusion exclusion principle (complex example)
- What is embedding (encoding an object into a low dimensional dense vector), NN in pytorch Principle and application of embedding
- mmdetection 学习率与batch_size关系
- Basic SQL tutorial
- Global and Chinese market of air cargo logistics 2022-2028: Research Report on technology, participants, trends, market size and share
- Mysql报错:[ERROR] mysqld: File ‘./mysql-bin.010228‘ not found (Errcode: 2 “No such file or directory“)
- C # realizes the login interface, and the password asterisk is displayed (hide the input password)
猜你喜欢
![[opengl] advanced chapter of texture - principle of flowmap](/img/dd/6208122fcc578caaf098301b185e03.jpg)
[opengl] advanced chapter of texture - principle of flowmap

Incluxdb2 buckets create database

Finally, someone explained the financial risk management clearly

cpu飙升排查方法

redis缓存穿透,缓存击穿,缓存雪崩解决方案
![Mysql报错:[ERROR] mysqld: File ‘./mysql-bin.010228‘ not found (Errcode: 2 “No such file or directory“)](/img/cd/2e4f5884d034ff704809f476bda288.png)
Mysql报错:[ERROR] mysqld: File ‘./mysql-bin.010228‘ not found (Errcode: 2 “No such file or directory“)

4-29——4.32

Composite type (custom type)

Solve the problem that pushgateway data will be overwritten by multiple push

ASTC texture compression (adaptive scalable texture compression)
随机推荐
[transformer] Introduction - the original author of Harvard NLP presented the annotated transformer in the form of line by line implementation in early 2018
北京共有产权房出租新规实施的租赁案例
CentOS7部署哨兵Redis(带架构图,清晰易懂)
从书本《皮囊》摘录的几个句子
TPS61170QDRVRQ1
基于SVN分支开发模式流程浅析
Solve the problem that pushgateway data will be overwritten by multiple push
What is embedding (encoding an object into a low dimensional dense vector), NN in pytorch Principle and application of embedding
Didi off the shelf! Data security is national security
App global exception capture
Global and Chinese markets for transparent OLED displays 2022-2028: Research Report on technology, participants, trends, market size and share
Yolov5系列(一)——网络可视化工具netron
[opengl] face pinching system
Redis主从、哨兵、集群模式介绍
The latest M1 dedicated Au update Adobe audit CC 2021 Chinese direct installation version has solved the problems of M1 installation without flash back!
[pytorch learning notes] transforms
Global and Chinese market of optical fiber connectors 2022-2028: Research Report on technology, participants, trends, market size and share
Detailed comments on MapReduce instance code on the official website
. Net six design principles personal vernacular understanding, please correct if there is any error
基础SQL教程