예제 #1
0
        public static void xmlToTimetable(string file)
        {
            FileStream xmlfs = new FileStream(file, FileMode.Open);
            XmlReader xmlr = XmlReader.Create(xmlfs);

            List<Cell> current = null;

            while (xmlr.Read())
            {
                if (xmlr.Name == "row" && xmlr.NodeType == XmlNodeType.Element)
                {
                    current = new List<Cell>();
                }
                else if (xmlr.Name == "item" && xmlr.NodeType == XmlNodeType.Element)
                {
                    string content = xmlr.ReadElementContentAsString();
                    Cell c = new Cell(content, null, content);
                    current.Add(c);
                }
                else if (xmlr.Name == "row" && xmlr.NodeType == XmlNodeType.EndElement)
                {
                    Row r = new Row(current);
                    Data.timetable.Add(r);
                }
            }
            xmlfs.Close();
        }
예제 #2
0
 private void button_timetable_save_Click(object sender, EventArgs e)
 {
     button_timetable_cancel.Enabled = false;
     button_timetable_save.Enabled = false;
     Data.timetable.Clear();
     foreach (DataGridViewRow dgvr in dataGridView_timeTable.Rows)
     {
         if (dgvr != dataGridView_timeTable.Rows[dataGridView_timeTable.Rows.Count - 1])
         {
             List<Cell> cells = new List<Cell>();
             foreach (DataGridViewCell cell in dgvr.Cells)
             {
                 Cell c;
                 if (cell.Value == null)
                 {
                     c = new Cell("", "", "");
                 }
                 else
                 {
                     c = new Cell(cell.Value.ToString(), "", cell.ToolTipText);
                 }
                 cells.Add(c);
             }
             Row r = new Row(cells);
             Data.timetable.Add(r);
         }
     }
 }