コード例 #1
0
ファイル: Program.cs プロジェクト: unaveed/Spreadsheet
 /// <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
ファイル: Form1.cs プロジェクト: aymomeni/Software-Practice-I
 /// <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());
 }