Example #1
0
        /// <summary>
        /// The method which handles when a spreadsheet is edited in the view.
        /// </summary>
        /// <param name="name">The name of the cell</param>
        /// <param name="contents">The new contents of the cell</param>
        private void HandleCellContentsChanged(string name, string contents)
        {
            HashSet <string> cellsToUpdate = new HashSet <string>();

            try
            {
                cellsToUpdate = (HashSet <string>)spreadsheet.SetContentsOfCell(name, contents);
            } catch (Exception e)
            {
                window.Message = e.Message;
                return;
            }
            window.CurrentCellName     = name;
            window.CurrentCellContents = spreadsheet.GetCellContents(name);
            object value = spreadsheet.GetCellValue(name);

            window.CurrentCellValue = value;

            foreach (string cellName in cellsToUpdate)
            {
                int col, row;
                reverseCellName(cellName, out col, out row);
                value = spreadsheet.GetCellValue(cellName);
                window.SetCellValueLabel(col, row, value);
            }
        }