コード例 #1
0
        /// <summary>
        /// Controller constructor for opening file.
        /// </summary>
        public Controller(ISpreadsheetGUI window, string filename)
        {
            this.window = window;
            TextReader reader = new StreamReader(filename);

            spreadsheet = new Spreadsheet(reader, new Regex(@"^[a-zA-Z]+[1-9][0-9]*$"));
            reader.Close();
            save = filename;
            foreach (string s in spreadsheet.GetNamesOfAllNonemptyCells())
            {
                window.Update(s, spreadsheet.GetCellValue(s).ToString());
            }
            string CellName = (((char)('A')).ToString()) + (1).ToString();

            window.CellName              = CellName;
            window.CellValue             = spreadsheet.GetCellValue(CellName).ToString();
            window.CellContents          = spreadsheet.GetCellContents(CellName).ToString();
            window.NewEvent             += HandleNew;
            window.CloseEvent           += HandleClose;
            window.KeyDownEvent         += HandleKeyDown;
            window.SelectionChangeEvent += HandleSelectionChange;
            window.ContentsChangeEvent  += HandleContentsChange;
            window.SaveCheckEvent       += HandleSaveCheck;
            window.OpenEvent            += HandleOpen;
            window.SaveEvent            += HandleSave;
            window.SavingEvent          += HandleSaving;
        }
コード例 #2
0
 /// <summary>
 /// Controller constructor.
 /// </summary>
 public Controller(ISpreadsheetGUI window)
 {
     this.window                  = window;
     spreadsheet                  = new Spreadsheet();
     save                         = "";
     window.NewEvent             += HandleNew;
     window.CloseEvent           += HandleClose;
     window.KeyDownEvent         += HandleKeyDown;
     window.SelectionChangeEvent += HandleSelectionChange;
     window.ContentsChangeEvent  += HandleContentsChange;
     window.SaveCheckEvent       += HandleSaveCheck;
     window.OpenEvent            += HandleOpen;
     window.SaveEvent            += HandleSave;
     window.SavingEvent          += HandleSaving;
 }