当前位置:网站首页>视觉上位系统设计开发(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会自动往后追加,比较方便。
好了以上就是全局变量的设计思路。
边栏推荐
- Global and Chinese market of Bus HVAC systems 2022-2028: Research Report on technology, participants, trends, market size and share
- Construction of operation and maintenance system
- Besides lying flat, what else can a 27 year old do in life?
- C language fcntl function
- [transformer] Introduction - the original author of Harvard NLP presented the annotated transformer in the form of line by line implementation in early 2018
- Chapter 14 class part 1
- Several sentences extracted from the book "leather bag"
- [engine development] in depth GPU and rendering optimization (basic)
- The picture quality has been improved! LR enhancement details_ Lightroom turns on AI photo detail enhancement: picture clarity increases by 30%
- 在MapReduce中利用MultipleOutputs输出多个文件
猜你喜欢
CentOS7部署哨兵Redis(带架构图,清晰易懂)
C # realizes the login interface, and the password asterisk is displayed (hide the input password)
[set theory] inclusion exclusion principle (complex example)
[attention mechanism] [first vit] Detr, end to end object detection with transformers the main components of the network are CNN and transformer
Qt—绘制其他东西
Construction of operation and maintenance system
Introduction to opengl4.0 tutorial computing shaders
Zero copy underlying analysis
B2020 分糖果
[graphics] adaptive shadow map
随机推荐
远程服务器后台挂起 nohup
SQL server安装位置改不了
4-29——4.32
socket.io搭建分布式Web推送服务器
Qt development - scrolling digital selector commonly used in embedded system
Solve the problem that pushgateway data will be overwritten by multiple push
Vs+qt application development, set software icon icon
Tencent internship interview sorting
Apache ant extension tutorial
[transformer] Introduction - the original author of Harvard NLP presented the annotated transformer in the form of line by line implementation in early 2018
【pytorch学习笔记】Datasets and Dataloaders
Yolov5 advanced 8 format conversion between high and low versions
Global and Chinese markets for flexible chips 2022-2028: Research Report on technology, participants, trends, market size and share
The first character of leetcode sword offer that only appears once (12)
Unity hierarchical bounding box AABB tree
[combinatorics] permutation and combination (set permutation, step-by-step processing example)
[ue4] geometry drawing pipeline
[opengl] advanced chapter of texture - principle of flowmap
What is machine reading comprehension? What are the applications? Finally someone made it clear
406. 根据身高重建队列