Example #1
0
        /// <summary>
        /// Opens a new spreadsheet form.
        /// </summary>
        private void OpenFile()
        {
            OpenFileDialog openSS = new OpenFileDialog();

            openSS.InitialDirectory = "c:\\";
            openSS.Filter           = "Spreadsheet File (*.sprd)| *.sprd | All Files (*.*)|*.*";
            openSS.DefaultExt       = "sprd";

            DialogResult r = openSS.ShowDialog();

            if (r == DialogResult.OK)
            {
                filename = openSS.FileName;
                try
                {
                    Form1 temp = new Form1(openSS.FileName);
                    temp.s = new Spreadsheet(filename, s => true, s => s.ToUpper(), "ps6");
                    SpreadSheetApplicationContext.getAppContext().DisplayForm(temp);

                    HashSet <string> HashNames = new HashSet <string>(temp.s.GetNamesOfAllNonemptyCells());
                    foreach (string cell in HashNames)
                    {
                        GetAddressOfCell(cell);
                        temp.spreadsheetPanel1.SetValue(column, row, cellValue(cell).ToString());
                    }
                    temp.DisplaySelection(temp.spreadsheetPanel1);
                }
                catch (IOException)
                {
                    MessageBox.Show("Cannot open File");
                }
            }
        }
Example #2
0
 /// <summary>
 /// Returns the one DemoApplicationContext.
 /// </summary>
 public static SpreadSheetApplicationContext getAppContext()
 {
     if (appContext == null)
     {
         appContext = new SpreadSheetApplicationContext();
     }
     return(appContext);
 }
Example #3
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            SpreadSheetApplicationContext appContext = SpreadSheetApplicationContext.getAppContext();

            appContext.DisplayForm(new Form1());
            Application.Run(appContext);
        }
Example #4
0
 /// <summary>
 /// Creates and shows a new form.
 /// </summary>
 private void NewForm()
 {
     SpreadSheetApplicationContext.getAppContext().DisplayForm(new Form1());
 }