Exemple #1
0
 /// <summary>
 /// Adds a folder of the right type to the radio settings
 /// </summary>
 /// <param name="folder"></param>
 public void AddFolder(RadioSWSettingsFolders folder)
 {
     if (!RadioFolders.Contains(folder))
     {
         RadioFolders.Add(folder);
     }
     //UpdateSweepersFolderPath();
 }
Exemple #2
0
        ///////////////////////////////////  STATIC VARS  ///////////////////////////////////

        //////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////  CONSTRUCTORS  ///////////////////////////////////
        //////////////////////////////////////////////////////////////////////////////////////

        public static void ClearSettings()
        {
            RadioSWSettings.AllRadioSWSettings = new List <RadioSWSettings>();
            RadioSWSettingsFolders.ClearFolderSettings();
        }
Exemple #3
0
        /// <summary>
        /// Gets the radio sweeper settings data from the xml file
        /// </summary>
        /// <param name="path"></param>
        public static void GetDataFromXMLFile(string path)
        {
            CurrentSettingsFilePath = path;
            XmlDocument doc = new XmlDocument();

            using (StreamReader sr = new StreamReader(path, Encoding.Default))
            {
                try { doc.Load(sr); }
                catch { }
            }

            if (!doc.HasChildNodes)   ////////////////// COME BACK COME BACK COME BACK COME BACK
            {
                if (main_window.CreateMessageBoxYesNo("No settings detected in file. Do you want to create them?", "Error: NO SETTINGS DETECTED!"))
                {
                    System.IO.Directory.CreateDirectory(DefaultSweeperSettingsDirectoryPath);
                    SweeperSelecctSettings.Initialize();
                }
            }
            else
            {
                XmlNode root = doc.FirstChild;
                if (root.Name == "SweeperSettings")
                {
                    XmlNodeList radio_children = root.ChildNodes;
                    foreach (XmlElement r in radio_children)
                    {
                        if (r.Name == "Radio")
                        {
                            //Gets the name and the letter of the given radio
                            RadioSWSettings radioSWS = new RadioSWSettings(r.GetAttribute("name"));
                            radioSWS.RadioLetter = r.GetAttribute("letter");
                            SweeperSettings.AllSweeperSettings.Add(radioSWS);

                            XmlNodeList folder_children = r.ChildNodes;
                            foreach (XmlElement ff in folder_children)
                            {
                                if (ff.Name == "Folders")
                                {
                                    foreach (XmlElement f in ff.ChildNodes)
                                    {
                                        RadioSWSettingsFolders fdr = new RadioSWSettingsFolders(f.GetAttribute("path"), radioSWS.RadioName);

                                        //Gets all child nodes including <Files> , <ExceptionFiles>, <SweepersPerHour> & <SweepersPerHourNumber>
                                        XmlNodeList folder_nodes = f.ChildNodes;
                                        foreach (XmlNode node in folder_nodes)
                                        {
                                            int n;
                                            if (node.Name == "Files" && node.InnerText != string.Empty)
                                            {
                                                fdr.Files = node.InnerText.Split(';').ToList();
                                            }
                                            if (node.Name == "ExceptionFiles" && node.InnerText != string.Empty)
                                            {
                                                fdr.ExceptionFiles = node.InnerText.Split(';').ToList(); fdr.UpdateFilesWithoutExceptionFiles();
                                            }
                                            if (node.Name == "SweepersPerHour")
                                            {
                                                fdr.PerHour = node.InnerText == "One" ? SweeperEveryHour.One :
                                                              (node.Value == "Two" ? SweeperEveryHour.Two :
                                                               (node.Value == "Number" ? SweeperEveryHour.Number :
                                                                (node.Value == "Norman" ? SweeperEveryHour.Normal : SweeperEveryHour.None)));
                                            }
                                            if (node.Name == "SweepersPerHourNumber")
                                            {
                                                fdr.PerHourNumber = int.TryParse(node.InnerText, out n) ? n : 0;
                                            }
                                        }
                                        radioSWS.AddFolder(fdr);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }