コード例 #1
0
        private void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //options for filetypes in the open file window
            openFileDialog1.Filter      = "All files (*.*)|*.*|xml files (*.xml)|*.xml";
            openFileDialog1.FilterIndex = 2;

            //checks if the user selected a file
            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {                             // loading from the xml file
                using (XMLInterface loadFile = new XMLInterface(openFileDialog1.OpenFile()))
                    if (loadFile != null) //if the path isnt null
                    {
                        try
                        {
                            sheet = loadFile.XMLLoad();
                            sheet.CellPropertyChanged += Sheet_CellPropertyChanged; //subscribes to the sheets event handler
                            selectedCell = sheet.GetCell(0, 49) as SpreadsheetCell; //sets a default selected cell to prevent crashes
                            ForceSheetUpdate();
                        }
                        catch (Exception except)
                        {
                            Console.WriteLine(except.Message);
                        }
                    }
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: DziLean/_5_oop
        private void listoxml_Click(object sender, EventArgs e)
        {
            if (formating.SelectedIndex < 0)
            {
                return;
            }
            if (ListOfAnimal.Count == 0)
            {
                return;
            }
            XMLInterface f = ListOfFormating[formating.SelectedIndex];

            f.Bind(new List <Object>(ListOfAnimal));
            f.ShowDialog();
        }
コード例 #3
0
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //options for filetypes in the save file window
            saveFileDialog1.Filter      = "All files (*.*)|*.*|xml files (*.xml)|*.xml";
            saveFileDialog1.FilterIndex = 2;

            if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                //using cleans up after itself by calling Dispose once its done.
                using (XMLInterface saveFile = new XMLInterface(saveFileDialog1.OpenFile())) //opens the save file window and makes an XMLInterface with the path
                    if (saveFile != null)                                                    //if the path isnt null
                    {
                        saveFile.XMLSave(sheet.GetUsedCells());
                    }                                           //write to the file
            }
        }