Beispiel #1
0
 /// <summary>
 /// Will set selection box and focus to cell content text box
 /// when form is first shown
 /// </summary>
 private void HandleFirstShown()
 {
     // Set selection box on start up to A1 or 0,0
     FormSpreadsheetPanel.SetSelection(0, 0);
     // Set focus
     CellContentTextBox.Focus();
 }
Beispiel #2
0
        /// <summary>
        /// Helper method that given an enumerable collection of cell names to update will update the corresponding values on a spreadsheet panel
        /// </summary>
        /// <param name="cellsToUpdate">enumerable collection of cells by name to update</param>
        private void UpdateSpreadsheetPanelValues(IEnumerable <string> cellsToUpdate)
        {
            // Update dependent cells value to display
            foreach (string cellNameToUpdate in cellsToUpdate)
            {
                object           cellValueToUpdate = spreadsheet.GetCellValue(cellNameToUpdate);
                Tuple <int, int> colRowToUpdate    = CellNameToColRow(cellNameToUpdate); // Convert the given cell name to a column and row location
                string           strCellValueToUpdate;
                if (cellValueToUpdate is FormulaError)                                   // With a FormulaError we will get the Reason and that will be the cell value
                {
                    strCellValueToUpdate = ((FormulaError)cellValueToUpdate).Reason;
                }
                else if (cellValueToUpdate is double) // With a double we convert to a string
                {
                    strCellValueToUpdate = cellValueToUpdate.ToString();
                }
                else // Otherwise we have a string so we cast to a string
                {
                    strCellValueToUpdate = (string)cellValueToUpdate;
                }


                FormSpreadsheetPanel.SetValue(colRowToUpdate.Item1, colRowToUpdate.Item2, strCellValueToUpdate); // Update displayed value
            }
        }
Beispiel #3
0
 /// <summary>
 /// Will add the content in cell content text box to cell then
 /// move selection on the form spreadsheet panel to the right preventing it from going beyond the edge.
 /// If movement would cause selection to go beyond edge nothing will happen.
 /// Returns true if key press was handled.
 /// </summary>
 /// <returns>true if key press was handled</returns>
 private bool MoveRight()
 {
     FormSpreadsheetPanel.GetSelection(out int col, out int row);
     if (col < 25)
     {
         AddCellContentToCurrentCell();
         FormSpreadsheetPanel.SetSelection((col + 1), row);
         UpdateTextBoxesAndFocus(FormSpreadsheetPanel);
     }
     return(true);
 }
Beispiel #4
0
 /// <summary>
 /// Will add the content in cell content text box to cell then
 /// move selection on the form spreadsheet panel down preventing it from going beyond the edge.
 /// If movement would cause selection to go beyond edge nothing will happen.
 /// Returns true if key press was handled.
 /// </summary>
 /// <returns>true if key press was handled</returns>
 private bool MoveDown()
 {
     FormSpreadsheetPanel.GetSelection(out int col, out int row);
     if (row < 98)
     {
         AddCellContentToCurrentCell();
         FormSpreadsheetPanel.SetSelection(col, (row + 1));
         UpdateTextBoxesAndFocus(FormSpreadsheetPanel);
     }
     return(true);
 }