当前位置:网站首页>视觉上位系统设计开发(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会自动往后追加,比较方便。
好了以上就是全局变量的设计思路。
边栏推荐
- 406. Reconstruct the queue according to height
- How does vs+qt set the software version copyright, obtain the software version and display the version number?
- Vs+qt application development, set software icon icon
- Puppet自动化运维排错案例
- Introduction to opengl4.0 tutorial computing shaders
- 2022/02/14
- Global and Chinese markets for ionization equipment 2022-2028: Research Report on technology, participants, trends, market size and share
- [opengl] advanced chapter of texture - principle of flowmap
- High quality workplace human beings must use software to recommend, and you certainly don't know the last one
- Using TCL (tool command language) to manage Tornado (for VxWorks) can start the project
猜你喜欢

What is machine reading comprehension? What are the applications? Finally someone made it clear

【Transformer】入门篇-哈佛Harvard NLP的原作者在2018年初以逐行实现的形式呈现了论文The Annotated Transformer

QT program font becomes larger on computers with different resolutions, overflowing controls

PS tips - draw green earth with a brush

Finally, someone explained the financial risk management clearly

5.2-5.3
![[ue4] material and shader permutation](/img/8f/7743ac378490fcd7b9ecc5b4c2ef2a.jpg)
[ue4] material and shader permutation

ASTC texture compression (adaptive scalable texture compression)

Functional modules and application scenarios covered by the productization of user portraits

运维体系的构建
随机推荐
Global and Chinese markets for indoor HDTV antennas 2022-2028: Research Report on technology, participants, trends, market size and share
4-20-4-23 concurrent server, TCP state transition;
What are the composite types of Blackhorse Clickhouse, an OLAP database recognized in the industry
[ue4] HISM large scale vegetation rendering solution
[graphics] real shading in Unreal Engine 4
官网MapReduce实例代码详细批注
CentOS7部署哨兵Redis(带架构图,清晰易懂)
TPS61170QDRVRQ1
Global and Chinese markets for flexible chips 2022-2028: Research Report on technology, participants, trends, market size and share
"Seven weapons" in the "treasure chest" of machine learning: Zhou Zhihua leads the publication of the new book "machine learning theory guide"
Global and Chinese market of marketing automation 2022-2028: Research Report on technology, participants, trends, market size and share
运维体系的构建
Nppexec get process return code
App全局异常捕获
Yolov5 advanced seven target tracking latest environment construction (II)
Yolov5 series (I) -- network visualization tool netron
[transform] [practice] use pytoch's torch nn. Multiheadattention to realize self attention
XWiki安装使用技巧
Global and Chinese market of lighting control components 2022-2028: Research Report on technology, participants, trends, market size and share
Zero copy underlying analysis