Exemplo n.º 1
0
        private void FormClosingHandler(object sender, EventArgs e)
        {
            string filename = "soundboard.config";

            using (FileStream fileStream = new FileStream(filename, FileMode.Create))
                using (StreamWriter sw = new StreamWriter(fileStream))
                    using (XmlTextWriter writer = new XmlTextWriter(sw))
                    {
                        writer.Formatting  = Formatting.Indented;
                        writer.Indentation = 4;

                        writer.WriteStartDocument();
                        writer.WriteStartElement("tabs");

                        for (int i = 0; i < Tabs.Items.Count; ++i)
                        {
                            MetroTabItem tab = (MetroTabItem)Tabs.Items[i];
                            if (tab.Content is Grid)
                            {
                                string name = tab.Header.ToString();
                                writer.WriteStartElement("tab");

                                writer.WriteElementString("name", name);


                                {
                                    Grid grid = (Grid)tab.Content;
                                    int  j    = 0;
                                    foreach (var child in grid.Children)
                                    {
                                        if (child is SoundButton)
                                        {
                                            SoundButton button = (SoundButton)child;
                                            writer.WriteStartElement("button" + j++);
                                            writer.WriteAttributeString("name", button.GetFileName());
                                            writer.WriteAttributeString("path", button.GetFile());
                                            //writer.WriteString("test");
                                            writer.WriteEndElement();
                                        }
                                    }
                                }

                                writer.WriteEndElement();
                            }
                            else // it doesn't have a grid, so it's not a sound page
                            {
                                continue;
                            }
                        }

                        writer.WriteEndElement();
                        writer.WriteEndDocument();
                    }
        }
Exemplo n.º 2
0
        public void UpdateSoundList()
        {
            sounds.Clear();

            foreach (MetroTabItem tab in Tabs.Items)
            {
                if (tab.Content is Grid)
                {
                    Grid grid = (Grid)tab.Content;
                    foreach (var child in grid.Children)
                    {
                        if (child is SoundButton)
                        {
                            SoundButton button = (SoundButton)child;
                            sounds[button.Content.ToString()] = button.GetFile();
                        }
                    }
                }
            }
        }