コード例 #1
0
        /// <summary>
        /// Initializes a controller for the given window.
        /// This is the controlling component in the MVC framework.
        /// </summary>
        /// <param name="window"></param>
        public Controller(ISpreadsheetView window, ISpreadsheetServer server, String SpreadsheetName)
        {
            _window          = window;
            _server          = server;
            _spreadsheetName = SpreadsheetName;
            SelectedCell     = new GuiCell(0, 0);
            Spreadsheet      = new Spreadsheet();
            _random          = new Random();
            Clients          = new Dictionary <string, Client>();

            // Event Subscriptions
            _window.CellValueBoxTextComplete += CellValueBarChanged;
            _window.CellSelectionChange      += SpreadsheetSelectionChanged;
            _window.CreateNew    += CreateNew;
            _window.HandleOpen   += () => HandleOpen(null);
            _window.HandleSave   += () => HandleSave(_savePath);
            _window.HandleSaveAs += () => HandleSave(null);
            _window.HandleClose  += HandleClose;
            _window.HandleHelp   += WindowOnHandleHelp;
            _window.HandleUndo   += Undo;

            //Setup defaults
            _window.SetSelection(SelectedCell.CellColumn, SelectedCell.CellRow);
            UpdateInfoBar($"{SelectedCell.CellName}: { SelectedCell.GetCellValue(Spreadsheet)}", Color.White);
            UpdateCellNameText();
            _window.SetTitle(_spreadsheetName);
        }