예제 #1
0
 /// <summary>
 /// Returns the one MyApplicationContext.
 /// </summary>
 public static MyApplicationContext getAppContext()
 {
     if (appContext == null) {
         appContext = new MyApplicationContext();
     }
     return appContext;
 }
예제 #2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

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

            appContext.RunForm(new Form1());
            Application.Run(appContext);
        }
예제 #3
0
        /// <summary>
        ///  Deals with the Open menu
        ///  This will handle existed spreadsheet. set all cell contents and values
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // pop up the open file dialog form exsising DLL.
            OpenFileDialog openDialog = new OpenFileDialog();

            openDialog.Filter           = "Sprd Document (*.sprd)|*.sprd|All files(*.*)|*.*";
            openDialog.Title            = "0pen";
            openDialog.InitialDirectory = @"C:\";
            int col, row;

            if (openDialog.ShowDialog() == DialogResult.OK)
            {
                //find the path
                string filename   = openDialog.FileName;
                Form1  openedForm = new Form1(filename);
                openedForm.Text       = filename;
                openedForm.recentName = filename;
                MyApplicationContext.getAppContext().RunForm(openedForm);

                try
                {
                    //find non-empty cells and save
                    foreach (string cellname in openedForm.myspreadsheet.GetNamesOfAllNonemptyCells())
                    {
                        convertToColRow(cellname, out col, out row);
                        openedForm.spreadsheetPanel1.SetValue(col, row, openedForm.myspreadsheet.GetCellValue(cellname).ToString());
                        openedForm.spreadsheetPanel1.SetSelection(col, row);
                        openedForm.displaySelection(spreadsheetPanel1);
                    }
                }
                catch (Exception er)
                {
                    MessageBox.Show(er.Message, "Error");
                    openedForm.Close();
                }
            }
        }
예제 #4
0
 /// <summary>
 ///  Deals with the New menu
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void newToolStripMenuItem_Click(object sender, EventArgs e)
 {
     MyApplicationContext.getAppContext().RunForm(new Form1());
 }
예제 #5
0
 /// <summary>
 /// Method that creates a new instance of the GUI
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void newToolStripMenuItem_Click(object sender, EventArgs e)
 {
     // Creates a new spreadsheet GUI
     MyApplicationContext.getAppContext().RunForm(new Form1());
 }