/// <summary> /// Checks if the data in the settings file misaligns with the data in the given folders /// </summary> public static void CheckIfUpdateNeeded() { bool changed = false; RadioSWSettings sws = new RadioSWSettings(); AllSweeperSettings.ForEach((x) => { x.RadioFolders.ForEach((y) => { List <string> files = System.IO.Directory.GetFiles(y.Folder).ToList(); if (files.Count == y.Files.Count) { files.ForEach((d) => { if (!y.Files.Contains(d)) { changed = true; } }); } else { changed = true; } }); }); if (changed) { ; //if (main_window.CreateMessageBoxYesNo("Changes have been made to the data in the sweepers location. Do you want to update the settings?", "Changes detected")) SweeperSelecctSettings.Initialize(); } }
private void UpdateSweeperSettings() { RadioSWSettings.CreateFromSweeperSelectSettings(Radios); SweeperSettings.CreateXMLSettingsFile(SweeperSettings.DefaultSweeperSettingsDirectoryPath + @"\SweeperSettings.sws.xml"); }
private void update_button_Click(object sender, EventArgs e) { RadioSWSettings.ClearAll(); UpdateSweeperSettings(); OnSweeperSettingsUpdate(); }
/// <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); } } } } } } } }