123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- using OTSIncAReportApp.DataOperation.DataAccess;
- 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;
- using static DevExpress.Diagram.Core.Native.Either;
- namespace OTSIncAReportApp._1_UI.Control_Grids.ParticlesGridDevidePage
- {
- public partial class ParticleClassificationSelect : Form
- {
- ParticleData Particledata;
- string[] ParticleClassificationSelectedList;
- public string ParticleClassificationSelected
- {
- get;
- set;
- }
- public ParticleClassificationSelect(ParticleData a_Particledata, string a_ParticleClassificationSelected)
- {
- InitializeComponent();
- Particledata = a_Particledata;
- ParticleClassificationSelectedList = a_ParticleClassificationSelected.Split('$');
- }
- private void ParticleClassificationSelect_Load(object sender, EventArgs e)
- {
- DataTable table = Particledata.GetClassificationOfAllParticles();
- //for (int i = 0; i < 30; i++)
- //{
- // DataRow row = table.NewRow();
- // row["TypeName"] = "aa" + i.ToString();
- // table.Rows.Add(row);
- //}
- if (table != null)
- {
- if (table.Rows.Count > 0)
- {
- FlowLayoutPanel flowLayoutPanel = new FlowLayoutPanel();
- flowLayoutPanel.FlowDirection = FlowDirection.LeftToRight;
- flowLayoutPanel.WrapContents = true;
- flowLayoutPanel.Dock = DockStyle.Fill;
- flowLayoutPanel.AutoScroll = true;
- flowLayoutPanel.Padding = new Padding(20, 10, 20, 25);
- panel1.Controls.Add(flowLayoutPanel);
- foreach (DataRow it in table.Rows)
- {
- // 添加控件到 FlowLayoutPanel 中
- CheckBox box1 = new CheckBox();
- box1.Text = it["TypeName"].ToString();
- box1.Width = flowLayoutPanel.Width-40;
- box1.Height = 25;
- Font font= new Font("宋体", 15, FontStyle.Regular);
- box1.Font = font;
- if (ParticleClassificationSelectedList != null)
- {
- if (ParticleClassificationSelectedList.Contains(box1.Text))
- {
- box1.Checked = true;
- }
- else
- {
- box1.Checked = false;
- }
- }
- else
- {
- box1.Checked = false;
- }
- flowLayoutPanel.Controls.Add(box1);
- }
- if (ParticleClassificationSelectedList.Count() == table.Rows.Count)
- {
- this.checkBox_selall.CheckedChanged -= new System.EventHandler(this.checkBox_selall_CheckedChanged);
- checkBox_selall.Checked = true;
- this.checkBox_selall.CheckedChanged += new System.EventHandler(this.checkBox_selall_CheckedChanged);
- }
- }
- }
- }
- private void btn_ok_Click(object sender, EventArgs e)
- {
- ParticleClassificationSelected = "";
- foreach (Control control in panel1.Controls)
- {
- if (control.GetType() == typeof(FlowLayoutPanel))
- {
- foreach (Control control1 in control.Controls)
- {
- if (control1.GetType() == typeof(System.Windows.Forms.CheckBox))
- {
- if (((CheckBox)control1).Checked)
- {
- ParticleClassificationSelected += control1.Text+ "$";
- }
- }
- }
- }
- }
- if(ParticleClassificationSelected!="")
- {
- ParticleClassificationSelected = ParticleClassificationSelected.Remove(ParticleClassificationSelected.Length - 1);
- }
- this.DialogResult = DialogResult.OK;
- this.Close();
- }
- private void btn_cannel_Click(object sender, EventArgs e)
- {
- this.DialogResult = DialogResult.Cancel;
- this.Close();
- }
- private void ParticleClassificationSelect_FormClosing(object sender, FormClosingEventArgs e)
- {
- this.Close();
- }
- private void checkBox_selall_CheckedChanged(object sender, EventArgs e)
- {
- if(checkBox_selall.Checked)
- {
- foreach (Control control in panel1.Controls)
- {
- if (control.GetType() == typeof(FlowLayoutPanel))
- {
- foreach (Control control1 in control.Controls)
- {
- if (control1.GetType() == typeof(System.Windows.Forms.CheckBox))
- {
- ((CheckBox)control1).Checked = true;
- }
- }
- }
- }
- }
- else
- {
- foreach (Control control in panel1.Controls)
- {
- if (control.GetType() == typeof(FlowLayoutPanel))
- {
- foreach (Control control1 in control.Controls)
- {
- if (control1.GetType() == typeof(System.Windows.Forms.CheckBox))
- {
- ((CheckBox)control1).Checked = false;
- }
- }
- }
- }
- }
- }
- }
- }
|