enginecheckbox.cs

来自「用C#编写的一个款搜索engine的源代码!摘自<Visual c#200」· CS 代码 · 共 84 行

CS
84
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using SECompare.Structure;

namespace SECompare.Controls
{
    public partial class EngineCheckBox : UserControl
    {
        public EngineCheckBox()
        {
            InitializeComponent();
            //初始化复选框
            this.InitializeCheckBoxes();
        }

        public new bool Enabled
        {
            get
            {
                return this.groupBox.Enabled;
            }
            set
            {
                this.groupBox.Enabled = value;
            }
        }

        public EngineSetting Checked
        {
            get
            {
                EngineSetting es = new EngineSetting();
                for (int i = 0; i < this.groupBox.Controls.Count; i++)
                {
                    Control c = this.groupBox.Controls[i];
                    if (c.GetType().Name.Equals("CheckBox"))
                    {
                        if (((CheckBox)c).Checked)
                            es.Select(((CheckBox)c).Name);
                        else
                            es.DisSelect(((CheckBox)c).Name);
                    }
                }
                return es;
            }
        }

        private void InitializeCheckBoxes()
        {
            String[] engines = Structure.EngineSetting.GetEngines();
            EngineSetting es = new EngineSetting();
            int i = 0;
            foreach (String engine in engines)
            {
                CheckBox cb = new CheckBox();
                cb.Name = engine;
                cb.Text = engine;
                cb.Location = new Point(10 + 80 * (i++), 20);
                cb.Size = new Size(70, 25);
                cb.Checked = es.IsSelected(EngineSetting.GetEnum(engine));

                this.groupBox.Controls.Add(cb);
            }

        }

        public bool IsChecked(EngineSet engine)
        {
            for (int i = 0; i < this.groupBox.Controls.Count; i++)
            {
                Control c = this.groupBox.Controls[i];
                if (c.GetType().Name.Equals("CheckBox") && c.Name.Equals(engine.ToString()))
                    return ((CheckBox)c).Checked;
            }
            return false;
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?