Пример #1
0
        /// <summary>
        /// A helper method that helps updates the visuals of the GUI.
        /// It will update tehe text boxes as well as the cells visuals.
        ///
        /// For Formula Error's it will set the cell's visual contents and
        /// the cell's contents in general to, Formula Error.
        ///
        /// The cursor is set to the end of the the contents text box as well.
        /// </summary>
        /// <param name="cellName"></param>
        private void SetTextBoxesVisuals(string cellName)
        {
            CellNameBox.Text = cellName;

            if (mainSpreadsheet.GetCellValue(cellName) is FormulaError)
            {
                CellValueBox.Text = "Formula Error";
            }
            else
            {
                CellValueBox.Text = mainSpreadsheet.GetCellValue(cellName).ToString();
            }

            if (mainSpreadsheet.GetCellContents(cellName) is Formula)
            {
                CellContentsBox.Text = "=" + mainSpreadsheet.GetCellContents(cellName).ToString();
            }
            else
            {
                CellContentsBox.Text = mainSpreadsheet.GetCellContents(cellName).ToString();
            }

            CellContentsBox.Focus();

            CellContentsBox.SelectionStart = CellContentsBox.Text.Length + 1;
        }
Пример #2
0
        /// <summary>
        /// Private method in our view (listener) to update our TextBoxes
        /// showing information about our current cell whenever a new
        /// box in our spreadsheet is selected.
        /// </summary>
        /// <param name="s">name of the cell we are cuurently on.</param>
        private void UpdateTextBoxes(string cellName)
        {
            CellNameBox.Text = cellName;

            CellValueBox.Clear();
            CellContentsBox.Clear();

            try
            {
                CellValueBox.Text = controller.GetCellValue(cellName).ToString();

                // Updating CellContentsBox with either a formula or another content.
                if (controller.GetCellContents(cellName) is Formula)
                {
                    CellContentsBox.Text = controller.GetCellContents(cellName).ToString().Insert(0, "=");
                }

                else
                {
                    CellContentsBox.Text = controller.GetCellContents(cellName).ToString();
                }
            }

            // Cell has not been added to spreadsheet yet, no contents or value to be found.
            catch (ArgumentException)
            {
            }
        }
Пример #3
0
        /// <summary>
        /// Visually updates the cell name, cell value, and cell contents boxes and then focusses on the cell contents box.
        /// </summary>
        /// <param name="cellName">Name of the cell that's being updated</param>
        private void VisualUpdate(string cellName)
        {
            CellNameBox.Text = cellName;

            if (mainSpreadsheet.GetCellValue(cellName) is FormulaError)
            {
                CellValueBox.Text = "Formula Error";
            }
            else
            {
                CellValueBox.Text = mainSpreadsheet.GetCellValue(cellName).ToString();
            }

            if (mainSpreadsheet.GetCellContents(cellName) is Formula)
            {
                CellContentsBox.Text = "=" + mainSpreadsheet.GetCellContents(cellName).ToString();
            }
            else
            {
                CellContentsBox.Text = mainSpreadsheet.GetCellContents(cellName).ToString();
            }

            CellContentsBox.Focus();
        }