// Every time the selection changes, this method is called with the // Spreadsheet as its parameter. We display the current time in the cell. private void displaySelection(SpreadsheetPanel ss) { int row, col; String value; ss.GetSelection(out col, out row); ss.GetValue(col, row, out value); if (value == "") { ss.SetValue(col, row, DateTime.Now.ToLocalTime().ToString("T")); ss.GetValue(col, row, out value); MessageBox.Show("Selection: column " + col + " row " + row + " value " + value); } }
// Every time the selection changes, this method is called with the // Spreadsheet as its parameter. We display the current time in the cell. private void displaySelection(SpreadsheetPanel ss) { int row, col; String value; ss.GetSelection(out col, out row); ss.GetValue(col, row, out value); if (value == "") { ss.SetValue(col, row, DateTime.Now.ToLocalTime().ToString("T")); ss.GetValue(col, row, out value); } }
// Every time the selection changes, this method is called with the // Spreadsheet as its parameter. We display the current time in the cell. private void displaySelection(SpreadsheetPanel ss) { int row, col; String value; ss.GetSelection(out col, out row); ss.GetValue(col, row, out value); if (value == "") { ss.SetValue(col, row, DateTime.Now.ToLocalTime().ToString("T")); ss.GetValue(col, row, out value); MessageBox.Show("Selection: column " + col + " row " + row + " value " + value); } }
public void OnSelectionChanged(SpreadsheetPanel panel) { panel.GetSelection(out int col, out int row); panel.SetValue(col, row, GetCellName(col, row)); }
/// <summary> /// Updates the panel display, cellDisplayTextBox, contentsTextBox, valueTextBox, and all non-empty Cells /// Every time the selection changes, this method is called with the Spreadsheet as its parameter. /// </summary> /// <param name="ss"></param> private void displaySelection(SpreadsheetPanel ss) { // Get col and row of cell. int row, col; ss.GetSelection(out col, out row); string nameOfCell = "" + GetExcelColumnName(col) + (row + 1); // get cell name // Cell Display cellDisplayBox.Text = nameOfCell; // Set the valueTextBox if there is a formula error make the error message be "###########" var valueOfCell = spreadsheet.GetCellValue(nameOfCell); // get value of cell string valueOfCellString; if (valueOfCell is SpreadsheetUtilities.FormulaError) { //clientCommunication. // If it is an FormulaError we don't do anytyhing here. valueOfCellString = "##########"; } else { /**If is isn't a FormulaError, we send "CHANGE VERSION #\n" to the server. * The state of the client’s local spreadsheet should remain unchanged until approved by the server. Socket.BeginSend("message", SendCallback, null/whatever); Socket.BeginReceive(ReceiveCallback, null/whatever); probably a loop with thread.sleep in it while we wait for the message. */ valueOfCellString = valueOfCell.ToString(); } valueTextBox.Text = valueOfCellString; ss.SetValue(col, row, valueOfCellString); // update panel var contentsOfCell = spreadsheet.GetCellContents(nameOfCell); // Set the contentsTextBox, append the '=' for convience if (contentsOfCell is SpreadsheetUtilities.Formula) { contentsTextBox.Text = "=" + contentsOfCell.ToString(); } else { contentsTextBox.Text = contentsOfCell.ToString(); ss.SetSelection(col, row); } // update all non empty cells IEnumerable<string> nonEmptyCells = spreadsheet.GetNamesOfAllNonemptyCells(); foreach (var name33 in nonEmptyCells) { Match m = Regex.Match(name33, @"^([A-Z]+) *(\d)$");// separate cell name if (m.Success) { // get the column letter and convert it to a number string translated = m.Groups[1].Value; int column = TranslateColumnNameToIndex(translated); int rowNumber = Int32.Parse(m.Groups[2].Value) - 1; string valueOfDependentCellString; var valueOfDependentCell = spreadsheet.GetCellValue(name33); // Set the value if there is a formula error if (valueOfDependentCell is SpreadsheetUtilities.FormulaError) { valueOfDependentCellString = "##########"; } else { valueOfDependentCellString = valueOfDependentCell.ToString(); } ss.SetValue(column, rowNumber, valueOfDependentCellString); // update panel } } // put cursor in contents text box contentsTextBox.Focus(); contentsTextBox.Select(contentsTextBox.Text.Length, 0); }