コード例 #1
0
ファイル: Form1.cs プロジェクト: njmull/server-client
        private void EnterPressed(SpreadsheetPanel ss)
        {
            int row, col;

            ss.GetSelection(out col, out row);

            String name = CellNameField.Text;

            ISet <String> altered  = null;
            ISet <String> circular = null;

            Model.Model.Edit(name, ContentField.Text);

            try
            {
                altered  = sheet.SetContentsOfCell(name, ContentField.Text);
                circular = new HashSet <string>();

                HashSet <string> visited = new HashSet <string>();

                //CS 3505 changes ////////////////////////////////////


                foreach (string cell in sheet.GetDirectDependents(name))
                {
                    if (!visited.Contains(cell))
                    {
                        CircularDependencyCheck(cell, cell, visited, circular);
                    }
                    circular.Add(cell);
                }


                foreach (String s in altered)
                {
                    updateCell(s, ss);
                }

                foreach (string c in circular)
                {
                    sheet.SetCellCircularStatus(c, false);
                }


                //    //end ////////////////////////////////////////////////

                displaySelection(ss);
            }
            catch (FormulaFormatException e)
            {
                MessageBox.Show("The formula you entered is not valid.");
            }
            catch (CircularException e)
            {
                MessageBox.Show("The formula you entered results in a circular exception.");
            }
            catch (Exception e)
            {
                MessageBox.Show("Unable to change cell value; " + e.Message);
            }
        }