程序代码

  1. 循环遍历获取控件

    List<LQOutPutCheckBox.LQOutPutCheckBox> AllLQOutputCheckControls = new List<LQOutPutCheckBox.LQOutPutCheckBox>();
    List<LQOutPutCheckBox.LQInputCheckBox> AllLQInputCheckControls = new List<LQOutPutCheckBox.LQInputCheckBox>();
    private void IOControlForm_Load(object sender, EventArgs e)
    {
    AllLQOutputCheckControls.Clear();
    AllLQInputCheckControls.Clear();
    GetAllControls_out(this, ref AllLQOutputCheckControls);
    GetAllControls_in(this, ref AllLQInputCheckControls);
    IsOnThread = true;
    CheckStateThread = new Thread(RefreshIO);
    CheckStateThread.Start();
    }

    private void GetAllControls_out(Control tempParentControl, ref List<LQOutPutCheckBox.LQOutPutCheckBox> tenpControlList)//循环遍历获得所有LQ控件
    {
        foreach (Control ctl in tempParentControl.Controls)//groupBox2.Controls)
        {
            LQOutPutCheckBox.LQOutPutCheckBox xxx = ctl as LQOutPutCheckBox.LQOutPutCheckBox;
            if (xxx != null)
            {
                Console.WriteLine("添加控件--" + ctl.Name);
                //xxx.MouseEnter += new System.EventHandler(this.SteelInputSideStopper_MouseEnter);
                tenpControlList.Add(xxx);
                continue;
            }
            //Console.WriteLine(ctl.Name);
            if (ctl.Controls.Count > 0)
            {
                Console.WriteLine("父控件---" + ctl.Name);
                GetAllControls_out(ctl, ref tenpControlList);
            }
            //else
            //{
            //    //Console.WriteLine("添加控件--" + ctl.Name);
            //    //LQOutPutCheckBox.LQOutPutCheckBox xxx = ctl as LQOutPutCheckBox.LQOutPutCheckBox;
            //    //if (xxx != null)
            //    //{
            //    //    Console.WriteLine("添加控件--", ctl.Name);
            //    //    //xxx.MouseEnter += new System.EventHandler(this.SteelInputSideStopper_MouseEnter);
            //    //    AllInpot.Add(xxx);
            //    //}
            //}
        }
    }
    
    private void GetAllControls_in(Control tempParentControl, ref List<LQOutPutCheckBox.LQInputCheckBox> tenpControlList)//循环遍历获得所有LQ控件
    {
        foreach (Control control in tempParentControl.Controls)
        {
            LQOutPutCheckBox.LQInputCheckBox tempInputControl = control as LQOutPutCheckBox.LQInputCheckBox;
            if (tempInputControl != null)
            {
                Console.WriteLine("添加控件--" + control.Name);
                tenpControlList.Add(tempInputControl);
                continue;
            }
            //Console.WriteLine(ctl.Name);
            if (control.Controls.Count > 0)
            {
                Console.WriteLine("父控件---" + control.Name);
                GetAllControls_in(control, ref tenpControlList);
            }
        }
    }
     private void RefreshIO()
    {
        while (IsOnThread == true && GlobalClass.FormClose == false)
        {
            if (AllLQOutputCheckControls != null)//刷新输出口LQ
            {
                foreach (LQOutPutCheckBox.LQOutPutCheckBox item in AllLQOutputCheckControls)
                {
                    item.RefreshInputPortState();
                }
            }
    
            if (IsOnThread == false)
                return;
    
            if (AllLQInputCheckControls != null)//刷新LQ输入口
            {
                foreach (LQOutPutCheckBox.LQInputCheckBox item in AllLQInputCheckControls)
                {
                    item.RefreshInputPortState();
                }
            }
        }
    }
    

导出与导入

导出

如果你想尝试使用此编辑器, 你可以在此篇文章任意编辑。当你完成了一篇文章的写作, 在上方工具栏找到 文章导出 ,生成一个.md文件或者.html文件进行本地保存。

导入

如果你想加载一篇你写过的.md文件或者.html文件,在上方工具栏可以选择导入功能进行对应扩展名的文件导入,
继续你的创作。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值