Ejemplo n.º 1
0
 /// <summary>
 /// Returns the one DemoApplicationContext.
 /// </summary>
 public static SpreadsheetApplicationContext getAppContext()
 {
     if (appContext == null)
     {
         appContext = new SpreadsheetApplicationContext();
     }
     return(appContext);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Returns the one DemoApplicationContext.
 /// </summary>
 public static SpreadsheetApplicationContext GetContext()
 {
     if (context == null)
     {
         context = new SpreadsheetApplicationContext();
     }
     return(context);
 }
Ejemplo n.º 3
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            SpreadsheetApplicationContext appContext = SpreadsheetApplicationContext.getAppContext();

            appContext.RunForm(new SpreadsheetForm());
            Application.Run(appContext);
        }
Ejemplo n.º 4
0
        public static SpreadsheetApplicationContext getAppContext()
        {
            if (appContext == null)
            {
                appContext = new SpreadsheetApplicationContext();
            }

            return appContext;
        }
Ejemplo n.º 5
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var context = SpreadsheetApplicationContext.GetContext();

            SpreadsheetApplicationContext.GetContext().RunNew();
            Application.Run(context);
        }
Ejemplo n.º 6
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));
     }
 }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Get the application context and run one form inside it
            var context = SpreadsheetApplicationContext.GetContext();

            SpreadsheetApplicationContext.GetContext().RunNew();
            Application.Run(context);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Opens the spreadsheet at source in a new window.
 /// </summary>
 /// <param name="source">Path of the spreadsheet</param>
 private void HandleOpen(string source)
 {
     try
     {
         Spreadsheet newSpreadsheet = new Spreadsheet(File.OpenText(source));
         SpreadsheetApplicationContext.GetContext().RunNewWithSpreadsheet(newSpreadsheet);
     }catch (IOException)
     {
         window.Message = "Error opening file";
     }
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Handles a request to open a file, throwing exception if anything goes wrong
 /// </summary>
 private void HandleFileChosen(String filename)
 {
     try
     {
         SpreadsheetApplicationContext.GetContext().RunNew(filename);
     }
     catch (Exception e)
     {
         view.ShowFileOpenErrorBox(e);
     }
 }
Ejemplo n.º 11
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));
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Handles a new window being opened
        /// </summary>
        private void HandleOpen(String filename)
        {
            Regex varPattern = new Regex(@"^[a-zA-Z][1-9]{1}[0-9]{0,1}$");

            try
            {
                TextReader tr = new StreamReader(File.OpenRead(filename));
                SpreadsheetApplicationContext.GetContext().RunNew(true, new Spreadsheet(tr, varPattern), filename);
            }
            catch (Exception)
            {
                MessageBox.Show("Open Failed");
            }
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Handles New menu
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 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 SpreadsheetGUI());
 }
Ejemplo n.º 14
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));
        }
Ejemplo n.º 15
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());
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Open an existinfg file in a new window
 /// </summary>
 /// <param name="filename"></param>
 public void OpenExisting(String filename)
 {
     SpreadsheetApplicationContext.GetContext().OpenNew(filename);
 }
Ejemplo n.º 17
0
 public void OpenSaved(string fileName)
 {
     SpreadsheetApplicationContext.GetContext().RunNew(fileName);
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Opens a new instance of a spreadsheet window.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void HandleSelectNew(object sender, EventArgs e)
 {
     SpreadsheetApplicationContext.GetContext().RunNew();
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Opens the help menu if clicked.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void helpToolStripMenuItem_Click(object sender, EventArgs e)
 {
     SpreadsheetApplicationContext.GetContext().OpenHelp();
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Handles creating a new document.
 /// </summary>
 public void CreateNew()
 {
     SpreadsheetApplicationContext.GetContext().RunLauncher();
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Handles opening a file and creates a new window with the spreadsheet being opened.
 /// If the spreadsheet fails to open a MessageBox is displayed with an appropriate error message.
 /// </summary>
 public void HandleOpen(string path)
 {
     SpreadsheetApplicationContext.GetContext().RunLauncher();
 }
Ejemplo n.º 22
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());
 }
Ejemplo n.º 23
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());
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Opens a new blank spreadsheet
 /// </summary>
 public void OpenNew()
 {
     //runs a new and empty spreadsheet
     SpreadsheetApplicationContext.GetContext().RunNew();
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Adds a new SpreadsheetWindow to the Application Context. Doing this opens the window
 /// and makes sure that the form doesn't close if the new window closes.
 /// </summary>
 private void NewToolStripMenuItem_Click(object sender, EventArgs e)
 {
     SpreadsheetApplicationContext.GetAppContext().RunForm(new SpreadsheetWindow());
 }
Ejemplo n.º 26
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());
 }
Ejemplo n.º 27
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());
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Fires event to pen new window
 /// </summary>
 public void OpenNew()
 {
     SpreadsheetApplicationContext.GetContext().RunNew();
 }
Ejemplo n.º 29
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));
 }