private void PasteData() { if (controllerDropList.Items.Count > 0) { string pasteText = Clipboard.GetText(); string IOType = IOTab.SelectedTab.Text; IODataCollection.dataTableType dtt = (IODataCollection.dataTableType)Array.IndexOf( Enum.GetNames(typeof(IODataCollection.dataTableType)), IOType); DataGridView dgv = new DataGridView(); switch (dtt) { case IODataCollection.dataTableType.Input: dgv = inputDGV; break; case IODataCollection.dataTableType.Output: dgv = outputDGV; break; case IODataCollection.dataTableType.Limit: dgv = limitDGV; break; } string controllerName = controllerDropList.SelectedValue as string; PasteFormPreviewWindow pfp = new PasteFormPreviewWindow(pasteText, dgv, dgvList, controllerName.Split('-')[0]); pfp.ShowDialog(); if (pfp.result) { DataTable ct = pfp.pTable; IODataCollection.AddTable(dtt, controllerName, ct); switch (dtt) { case IODataCollection.dataTableType.Input: inputDGV.Sort(inputDGV.Columns["IOName"], ListSortDirection.Ascending); break; case IODataCollection.dataTableType.Output: outputDGV.Sort(outputDGV.Columns["IOName"], ListSortDirection.Ascending); break; case IODataCollection.dataTableType.Limit: limitDGV.Sort(limitDGV.Columns["IOName"], ListSortDirection.Ascending); break; } } } else { MessageBox.Show("请先添加控制器", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); childItemManageControllers.PerformClick(); } }
private void tableAddButton_Click(object sender, EventArgs e) { if (CheckTableEmpty()) { MessageBox.Show("没有限位定义", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); } else { DialogResult r = MessageBox.Show("将覆盖原有IO表,是否继续", "提示" , MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (DialogResult.Yes == r) { DataTable table = limitDGV.DataSource as DataTable; table.AcceptChanges(); Invoke(new Action(() => { IODataCollection.AddTable(IODataCollection.dataTableType.Limit, controllerName, table); })); } } }