using GeBoShi.SysCtrl; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace GeBoShi.UI.InageShow { public partial class EditPauseFrm : Form { public List lstCodes = new List(); private JArray DefectItemList; public EditPauseFrm(List codes, JArray defectItemList) { InitializeComponent(); DefectItemList = defectItemList; init(codes); } private void init(List codes) { var list = DefectItemList.Select(x => new { code = x.Value("code"), name = x.Value("name") }).ToList(); foreach (var item in list) { CheckBox uiCheckbox = new CheckBox(); uiCheckbox.Height = 50; uiCheckbox.Width = 150; uiCheckbox.Tag = item.code; uiCheckbox.Text = item.name; if (codes == null || codes.Count == 0) uiCheckbox.Checked = true; else uiCheckbox.Checked = codes.Contains(item.code); this.flowLayoutPanel1.Controls.Add(uiCheckbox); } } private void skinButton1_Click(object sender, EventArgs e) { for (int i = 0; i < this.flowLayoutPanel1.Controls.Count; i++) { CheckBox uiCheckbox = this.flowLayoutPanel1.Controls[i] as CheckBox; if (uiCheckbox.Checked) lstCodes.Add(uiCheckbox.Tag.ToString()); } this.DialogResult = DialogResult.OK; //if (lstCodes.Count < 1) //{ // MessageBox.Show("必需选择缺陷!","警告"); // return; //} } private void skinButton2_Click(object sender, EventArgs e) { this.Close(); this.DialogResult = DialogResult.Cancel; } } }