Ejemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();

            Words = new ObservableSet <Word>();

            Switch.pageSwitcher = this;
            Switch.SwitchIt(new MainPage());


            Words = ReadXML.ReadWords();

            DataContext = this;
        }
Ejemplo n.º 2
0
        public static void WriteWords(ObservableSet <Word> words)
        {
            XmlTextWriter writer = new XmlTextWriter(getXmlFile(), null);

            writer.Formatting = Formatting.Indented;

            writer.WriteStartElement("words");
            if (words != null)
            {
                foreach (var word in words)
                {
                    writer.WriteStartElement("word");

                    writer.WriteStartAttribute("label");
                    writer.WriteString(word.Label);
                    writer.WriteEndAttribute();

                    writer.WriteStartAttribute("category");
                    writer.WriteString(word.Category);
                    writer.WriteEndAttribute();

                    writer.WriteStartAttribute("body");
                    writer.WriteString(word.Body);
                    writer.WriteEndAttribute();

                    writer.WriteStartAttribute("picturePath");
                    writer.WriteString(word.Picture);
                    writer.WriteEndAttribute();

                    writer.WriteEndElement();
                }
            }

            writer.WriteEndElement();

            writer.Flush();
            writer.Close();
        }