Пример #1
0
        /// <summary>
        /// This method is run when the 'New' button is clicked.  The method opens
        /// a new spreadsheet panel in a new window.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <citation>Referenced from PS6 Skeleton 'Demo' class</citation>
        private void newMenuItem_Click(object sender, EventArgs e)
        {
            SpreadsheetForm newForm = new SpreadsheetForm();
            int             count   = SpreadsheetApplicationContext.getAppContext().RunForm(newForm);

            newForm.Text = "Spreadsheet" + count; // iterate the number in the spreadsheet title
        }
        // Deals with the New menu
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Tell the application context to run the form on the same
            // thread as the other forms.

            SpreadsheetApplicationContext.getAppContext().RunForm(new SpreadsheetGUIForm());
        }
Пример #3
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            SpreadsheetApplicationContext appContext = SpreadsheetApplicationContext.getAppContext();

            appContext.RunForm(new SpreadsheetForm());
            Application.Run(appContext);
        }
Пример #4
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Start an application context and run one form inside it
            SpreadsheetApplicationContext appContext = SpreadsheetApplicationContext.getAppContext();

            appContext.RunForm(new MainForm());
            Application.Run(appContext);
        }
Пример #5
0
 /// <summary>
 /// Creates a new window, connected to a server based on whether or not the previous windows is connected.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void NewSpreadsheetButton_Click(object sender, EventArgs e)
 {
     if (connected)
     {
         SpreadsheetApplicationContext.getAppContext().RunForm(new Form1(_address, winNum + 1));
     }
     else
     {
         SpreadsheetApplicationContext.getAppContext().RunForm(new Form1(winNum + 1));
     }
 }
Пример #6
0
        /// <summary>
        /// Triggered when the Open option is selected in the file menu
        /// Opens the file explorer and allows the user to pick an already existing .sprd file
        /// Creates a new Form1 based off this file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Open_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter = "Text Files (*.sprd)|*.sprd|All Files (*.*)|*.*";
            dialog.ShowDialog();
            string savePath = dialog.FileName;

            if (!string.IsNullOrWhiteSpace(savePath))
            {
                SpreadsheetApplicationContext.getAppContext().RunForm(new Form1(savePath));
            }
        }
Пример #7
0
 /// <summary>
 /// Button that creates a new blank spreadsheet. Does not close current one.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void NewToolStripMenuItem_Click(object sender, EventArgs e)
 {
     // Create a new form in the appcontext
     SpreadsheetApplicationContext.getAppContext().RunForm(new Form1());
 }
Пример #8
0
 /// <summary>
 /// Triggered when the New button is clicked in the file menu
 /// Creates a new Form1
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void new_spreadsheet_click(object sender, EventArgs e)
 {
     SpreadsheetApplicationContext.getAppContext().RunForm(new Form1());
 }
Пример #9
0
        /// <summary>
        /// A method that creates key bindings
        /// </summary>
        /// <Citation> https://www.daniweb.com/programming/software-development/threads/261384/disabling-arrow-keys-other-beginner-questions </Citation>
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            //If the user enters Alt + F4, closes the spreadsheet
            if (keyData == (Keys.Alt | Keys.F4))
            {
                CloseSpreadsheet();
                //Returns true after the operation was completed
                return(true);
            }
            //If the user enters Ctrl + S, closes the spreadsheet
            if (keyData == (Keys.Control | Keys.S))
            {
                SaveSpreadsheet();
                //Returns true after the operation was completed
                return(true);
            }
            //If the user enters Ctrl + O, opens the spreadsheet
            if (keyData == (Keys.Control | Keys.O))
            {
                OpenSpreadsheet();

                //Returns true after the operation was completed
                return(true);
            }
            //If the user enters Ctrl + N, creates a new spreadsheet
            if (keyData == (Keys.Control | Keys.N))
            {
                SpreadsheetApplicationContext.getAppContext().RunForm(new SpreadsheetForm());
                //Returns true after the operation was completed
                return(true);
            }
            //If the user enters Ctrl + H, shows the help options
            if (keyData == (Keys.Control | Keys.H))
            {
                HelpSpreadsheet();
                //Returns true after the operation was completed
                return(true);
            }
            //If the user enters Ctrl + C, clears the spreadsheet
            if (keyData == (Keys.Control | Keys.C))
            {
                ClearSpreadsheet();
                //Returns true after the operation was completed
                return(true);
            }


            //If the user enters the down key, then goes in here
            if (keyData == Keys.Down)
            {
                int col;
                int row;

                //Gets the row and col in the panel
                spreadsheetPanel.GetSelection(out col, out row);
                //If the row is less than 98, then goes in here
                if (row < 98)
                {
                    //Adds 1 to row number
                    row = row + 1;

                    //moves the cellHighlighted
                    moveCellHighlighted(col, row);
                }
                //Returns true after the change is made in the cell
                return(true);
            }
            //Condition if the user enters the left key
            if (keyData == Keys.Left)
            {
                int col;
                int row;

                //Gets the row and col of the spreadsheet
                spreadsheetPanel.GetSelection(out col, out row);
                //If the col is greater than 0, goes in here
                if (col > 0)
                {
                    //Subtracts by 1 to move left
                    col = col - 1;

                    //moves the cellHighlighted
                    moveCellHighlighted(col, row);
                }
                //Returns true after the change is made in the cell
                return(true);
            }
            //Goes in if the user enters the up key
            if (keyData == Keys.Up)
            {
                int col;
                int row;
                //Gets the selection based on the row and col of the spreadsheet
                spreadsheetPanel.GetSelection(out col, out row);
                if (row > 0)
                {
                    //Subtracts from the row to move up
                    row = row - 1;

                    cellContentsTextBox.Enabled = false;
                    //moves the cellHighlighted
                    moveCellHighlighted(col, row);

                    cellContentsTextBox.Enabled = true;
                    cellContentsTextBox.Select();
                }
                //Returns true after the change is made in the cell
                return(true);
            }

            //If the user enters the right key goes in here
            if (keyData == Keys.Right)
            {
                int col;
                int row;
                //Gets the selection based on the row and col of the spreadsheet
                spreadsheetPanel.GetSelection(out col, out row);
                //If the col is less than 25, goes in here
                if (col < 25)
                {
                    //Increments the col by 1
                    col = col + 1;
                    //Sets the selection on the basis of the row and col
                    spreadsheetPanel.SetSelection(col, row);

                    //moves the cellHighlighted
                    moveCellHighlighted(col, row);
                }
                //Returns true after the change is made in the cell
                return(true);
            }

            //Returns true if a key was pressed
            return(base.ProcessCmdKey(ref msg, keyData));
        }
Пример #10
0
 /// <summary>
 /// Creates a new SpreadSheet when the New button is clicked from the file drop down menu.
 /// </summary>
 private void newSpreadsheet_Click(object sender, EventArgs e)
 {
     //opens a new window
     SpreadsheetApplicationContext.getAppContext().RunForm(new SpreadsheetForm());
 }
Пример #11
0
 //Deals with click on New menu item
 private void NewMenuItem_Click_1(object sender, EventArgs e)
 {
     //Tell the application context to run the form on the same thread as the other forms.
     //Creats a new spreadsheet window
     SpreadsheetApplicationContext.getAppContext().RunForm(new Form1());
 }
Пример #12
0
 /// <summary>
 /// Event handler for "how to use" menu item
 /// </summary>
 /// <param name="sender">Object sending event</param>
 /// <param name="e">Event arguments</param>
 private void howToUseToolStripMenuItem_Click(object sender, EventArgs e)
 {
     SpreadsheetApplicationContext.getAppContext().RunForm(new HowToUseForm());
 }
Пример #13
0
 /// <summary>
 /// Event handler for the "bar graph" menu item
 /// </summary>
 /// <param name="sender">Object sending event</param>
 /// <param name="e">Event arguments</param>
 private void barGraphToolStripMenuItem_Click(object sender, EventArgs e)
 {
     SpreadsheetApplicationContext.getAppContext().RunForm(new ChartForm(spreadSheet));
 }