예제 #1
0
파일: SIR-CS.cs 프로젝트: ramcnamara/SIR-CS
        private void NewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Scheme        newScheme = new Scheme();
            SIRSchemeForm newChild  = new SIRSchemeForm(newScheme)
            {
                MdiParent = this
            };

            newChild.Text = "<New>";
            newChild.Show();
        }
예제 #2
0
파일: SIR-CS.cs 프로젝트: ramcnamara/SIR-CS
        private void OpenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openMSdlg.FileName = "";
            openMSdlg.Filter   = "MADAM marking schemes|*.xml|All files|*.*";
            openMSdlg.ShowDialog();
            string myFile = openMSdlg.FileName;

            // TODO: check that file open succeeded
            XmlSerializer serializer = new XmlSerializer(typeof(Scheme));

            System.IO.FileStream infile = null;
            try
            {
                infile = new System.IO.FileStream(myFile, System.IO.FileMode.Open);
            }
            catch (System.IO.IOException ee)
            {
                MessageBox.Show("There was a problem reading from that file.  " +
                                "Check that it is not being used by another program, and that " +
                                "you have permission to open it.  \n\nTechnical details: " + ee.Message,
                                "IO exception on load",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            XmlReader reader = XmlReader.Create(infile);

            Scheme newScheme;

            newScheme = (Scheme)serializer.Deserialize(reader);
            // TODO: check that deserialization worked
            reader.Close();

            // create MDI child window holding opened marking scheme
            SIRSchemeForm newChild = new SIRSchemeForm(newScheme, myFile)
            {
                MdiParent = this
            };

            newChild.Show();
        }