private void UpdateContents(string name, string contents)
        {
            var ReturnPairs = new Dictionary <string, string>();

            try
            {
                foreach (string cell in sheet.SetContentsOfCell(name, contents))
                {
                    //Need to be careful how we handle Formula Errors here.
                    if (sheet.GetCellValue(cell).GetType() == typeof(FormulaError))
                    {
                        ReturnPairs.Add(cell, "Formula Error");
                    }
                    else
                    {
                        string tempvalue = sheet.GetCellValue(cell).ToString();
                        ReturnPairs.Add(cell, tempvalue);
                    }
                }
                window.UpdateView(ReturnPairs);
            }
            catch (CircularException ex)
            {
                //MessageBox goes here saying that circular exceptions are bad.
                window.Message = ex.Message;
            }
            catch
            {
                //Would be nice to output the error messages that ive baked into each exception in spreadsheet but not sure how to do it.
                window.Message = "An Error has occured.";
            }
        }
        /// <summary>
        /// Begins controlling window.
        /// </summary>
        public Controller(IAnalysisView window, Spreadsheet ss)
        {
            this.window = window;
            this.sheet  = ss;
            var setvalues = new Dictionary <string, string>();

            foreach (string s in ss.GetNamesOfAllNonemptyCells())
            {
                setvalues.Add(s, ss.GetCellValue(s).ToString());
            }
            window.UpdateView(setvalues);
            //window.FileChosenEvent += HandleFileChosen;

            window.SetContents    += UpdateContents;
            window.GetContents    += PassBackContents;
            window.FileCloseEvent += HandleClose;
            window.NewEvent       += HandleNew;
            window.FileSaveEvent  += HandleSave;
            window.FileOpenEvent  += HandleOpen;
        }