public static void Pause(string copyData, DataGridView tableView) { var table = ParseCopyData(copyData); var cells = tableView.SelectedCells; var selectTable = new CellTable(tableView.SelectedCells); if (selectTable.Count > 0 && selectTable[0].Count > 0) { var fristCell = selectTable[0][0]; foreach (var row in selectTable) { foreach (var cell in row) { var x = cell.RowIndex - fristCell.RowIndex; var y = cell.ColumnIndex - fristCell.ColumnIndex; while (x >= table.Count) { x -= table.Count; } while (y >= table[x].Count) { y -= table[x].Count; } if (cell != null && cell.OwningColumn.Name != DataTableExtend.IndexCol) { cell.ChangeValue(table[x][y]); } } } } }
private void CopyToolStripMenuItem_Click(object sender, EventArgs e) { if (!isEditMode) { Clipboard.SetText(CellTable.Copy(tableView.SelectedCells)); statusLabel.Text = "复制成功"; } }
private void pasteToolStripMenuItem_Click(object sender, EventArgs e) { if (!isEditMode) { CellTable.Pause(Clipboard.GetText(), tableView); statusLabel.Text = "粘贴成功"; } }
public static void ScriptPause(string copyData, DataGridView tableView) { var table = ParseCopyData(copyData); var cells = tableView.SelectedCells; var selectTable = new CellTable(tableView.SelectedCells); if (selectTable.Count > 0 && selectTable[0].Count > 0) { for (int x = 0; x < table.Count; x++) { for (int y = 0; y < table[x].Count; y++) { var cell = selectTable[x, y]; if (cell != null && cell.OwningColumn.Name != DataTableExtend.IndexCol) { selectTable[x, y].ChangeValue(table[x][y]); } } } } }
private void tableView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.ColumnIndex < 0 || e.RowIndex < 0 || e.RowIndex >= tableView.Rows.Count - 1) { return; } var cell = tableView[e.ColumnIndex, e.RowIndex]; // var rect = cell.ContentBounds; var info = tableInfo[cell.OwningColumn.Name]; if (cell.ReadOnly) { if (info != null && info.type == ViewType.脚本) { FileManager.Save(TempPath, cell.Value.ToString().GetXmlInnerString()); var process = Process.Start(AppPath + "\\" + info.typeValues[0], TempPath); process.WaitForExit(); ParseInnerXml(cell.ColumnIndex, tableView.GetRowIndex(e.RowIndex), cell.Value.ToString()); var text = Clipboard.GetText(); var count = 1; foreach (var c in text) { if (c.Equals('\n')) { count++; } } while (curData.data.Rows.Count <= count) { curData.data.Rows.Add(); } foreach (DataGridViewRow row in gridView.Rows) { foreach (DataGridViewCell c in row.Cells) { if (!c.ReadOnly && c.RowIndex != gridView.Rows.Count - 1) { c.Value = ""; c.Selected = true; } } } CellTable.ScriptPause(text, tableView); statusLabel.Text = "脚本编辑成功"; } else { ParseInnerXml(cell.ColumnIndex, tableView.GetRowIndex(e.RowIndex), cell.Value.ToString()); } // gridView.Rows[0].Cells[0].Selected = true; } if (info != null && cell.Value != null && !string.IsNullOrEmpty(cell.Value.ToString())) { if (info.type == ViewType.表索引) { var process = Process.Start(Process.GetCurrentProcess().MainModule.FileName, info.TablePath + " " + cell.Value); SetForegroundWindow(FindWindow(null, process.MainWindowTitle)); } } }