Beispiel #1
0
        private ISpreadsheetWindow window; // reference to the GUI (view)

        /// <summary>
        /// Creates a new controller which controls an ISpreadsheetWindow and contains a reference to
        /// a spreadsheet model.
        /// </summary>
        public Controller(ISpreadsheetWindow spreadsheetWindow)
        {
            // get the reference of the GUI
            window = spreadsheetWindow;

            // set the window name at the top of the form
            window.WindowText = "untitled.sprd";

            // create a new model
            string version = "ps6";

            sheet = new SS.Spreadsheet(CellValidator, CellNormalizer, version);

            // register methods with events
            SpreadsheetPanel panel = window.GetSpreadsheetPanel();

            panel.SelectionChanged += DisplayCurrentCellName;
            panel.SelectionChanged += SetCellValueBox;
            panel.SelectionChanged += SetCellContentsBox;

            window.NewSheetAction      += OpenNewSheet;
            window.EnterContentsAction += SetCellContentsFromContentsBox;
            window.SetDefaultAcceptButton();

            window.SaveFileAction += Save;
            window.OpenFileAction += Open;
            window.AddFormClosingAction(ModifiedSpreadsheetDialogueBox);
            window.AboutText    += OpenAbout;
            window.HowToUseText += OpenHowToUse;

            // set default locations
            panel.SetSelection(0, 0);
            UpdateCurrentCellBoxes();
        }
Beispiel #2
0
        /// <summary>
        /// Creates a new controller which controls an ISpreadsheetWindow and contains a reference to
        /// a spreadsheet model.
        /// </summary>
        public Controller(ISpreadsheetWindow spreadsheetWindow)
        {
            // get the reference of the GUI
            window = spreadsheetWindow;

            // set the window name at the top of the form
            window.WindowText = "YOU ARE OFFLINE";

            // create a new model
            string version = "ps6";

            sheet = new SS.Spreadsheet(CellValidator, CellNormalizer, version);

            clientCells = new Dictionary <string, string>();

            // register methods with events
            SpreadsheetPanel panel = window.GetSpreadsheetPanel();

            panel.SelectionChanged += DisplayCurrentCellNameDelegate;
            panel.SelectionChanged += SetCellValueBoxDelegate;
            panel.SelectionChanged += SetCellContentsBoxDelegate;
            panel.SelectionChanged += SendFocusToServerDelegate;

            window.ArrowSelectionChanged += DisplayCurrentCellName;
            window.ArrowSelectionChanged += SetCellValueBox;
            window.ArrowSelectionChanged += SetCellContentsBox;
            window.ArrowSelectionChanged += SendFocusToServer;

            window.EnterContentsAction += SendEditToServer;
            window.SetDefaultAcceptButton();

            window.AddFormClosingAction(FormCloses);
            window.AboutText    += OpenAbout;
            window.HowToUseText += OpenHowToUse;

            window.Startup += IPInputBox;
            window.Undo    += SendUndoToServer;
            window.Revert  += SendRevertToServer;

            window.Ping    += Ping;
            window.Timeout += Timeout;

            // set default locations
            panel.SetSelection(0, 0);
            UpdateCurrentCellBoxes();
        }