Ejemplo n.º 1
0
        private void dataGridView3_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0 && e.RowIndex != -1)
            {
                DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dataGridView3.Rows[e.RowIndex].Cells[0];
                if ((bool)checkCell.EditedFormattedValue == true)     //
                {
                    string apidName = (string)Data.dtAPID.Rows[e.RowIndex]["名称"];

                    APIDForm form = new APIDForm(apidName, this);
                    form.Show(this.dockPanel1);
                    form.DockTo(this.dockPanel1, DockStyle.Fill);

                    Data.APID_Struct aPID_Struct = new Data.APID_Struct();
                    aPID_Struct.apidForm = form;
                    aPID_Struct.apidName = apidName;
                    Data.ApidList.Add(aPID_Struct);
                }
                else
                {
                    for (int i = 0; i < Data.ApidList.Count; i++)
                    {
                        string apidName = (string)Data.dtAPID.Rows[e.RowIndex]["名称"];

                        if (apidName == Data.ApidList[i].apidName)
                        {
                            Data.ApidList[i].apidForm.Close();
                            // Data.ApidList.Remove(Data.ApidList[i]);
                            break;
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void 一键启动APIDToolStripMenuItem_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < dataGridView3.Rows.Count; i++)
            {
                DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dataGridView3.Rows[i].Cells[0];
                checkCell.Value = true;

                string apidName = (string)Data.dtAPID.Rows[i]["名称"];
                if (apidName != "填充帧")
                {
                    bool AlreadyShowTag = false;
                    for (int j = 0; j < Data.ApidList.Count; j++)
                    {
                        if (apidName == Data.ApidList[j].apidName)
                        {
                            AlreadyShowTag = true;
                            break;
                        }
                        else
                        {
                            AlreadyShowTag = false;
                        }
                    }

                    if (!AlreadyShowTag)
                    {
                        APIDForm form = new APIDForm(apidName, this);
                        form.Show(this.dockPanel1);
                        form.DockTo(this.dockPanel1, DockStyle.None);

                        Data.APID_Struct aPID_Struct = new Data.APID_Struct();
                        aPID_Struct.apidForm = form;
                        aPID_Struct.apidName = apidName;
                        Data.ApidList.Add(aPID_Struct);
                        if (i == (dataGridView3.Rows.Count - 2))
                        {
                            Data.ApidList[0].apidForm.Activate();
                        }
                    }
                    else
                    {
                        Trace.WriteLine("Already show in the dock!");
                    }
                }
                else
                {
                    checkCell.Value = false;
                }
            }
        }