/// <summary> /// Reads the custom tools xml file and add the found tools to the display /// </summary> /// <param name="filePath">Path to the XML file</param> private void readCustomXML(string filePath) { XmlDocument myXmlDocument = new XmlDocument(); myXmlDocument.Load(filePath); XmlNodeList repos = myXmlDocument.SelectNodes("/data/tools/tool"); int id = customToolsStartId; foreach (XmlNode repo in repos) { string name = repo["name"].InnerText; string desc = repo["desc"].InnerText; string path = repo["path"].InnerText; RepoDispControl dispControl = new RepoDispControl() { ApplicationId = id, ApplicationName = name, ApplicationDescription = desc, ApplicationEnabled = true, }; dispControl.ButtonClick += new EventClick(ButtonClickCustom); dispControl.SwitchChecked += new EventChecked(SwitchCheckedCustom); dispControl.DownloadPercent = 1.0; dispControl.IsDownloaded = true; dispControls.Add(id, dispControl); panelRepo.Children.Add(dispControl); id++; } }
/// <summary> /// Reads the main XML file and adds tools to the display /// </summary> /// <param name="path"></param> private void readXML(string path) { var toolSettingsList = new List <ToolSettings>(); XmlDocument myXmlDocument = new XmlDocument(); myXmlDocument.Load(path); XmlNodeList repos = myXmlDocument.SelectNodes("/data/repos/repo"); int id = 0; foreach (XmlNode repo in repos) { string owner = repo["owner"].InnerText; string app = repo["app"].InnerText; string name = repo["name"].InnerText; string desc = repo["desc"].InnerText; string exe = repo["exe"].InnerText; Settings.Default.Reload(); List <ToolSettings> settingsList = Settings.Default.ToolSettings; if (settingsList == null) { Settings.Default.ToolSettings = new List <ToolSettings>(); Settings.Default.Save(); } Settings.Default.Reload(); settingsList = Settings.Default.ToolSettings; if (settingsList.Count <= id) { Settings.Default.ToolSettings.Add(new ToolSettings()); Settings.Default.Save(); } bool enabled = Settings.Default.ToolSettings[id].Enabled; bool downloaded = Settings.Default.ToolSettings[id].Downloaded; string currentVer = Settings.Default.ToolSettings[id].CurrentVersion; repositories.Add(id, new GithubRepository { Owner = owner, App = app, Name = name, Description = desc, Exe = exe }); RepoDispControl dispControl = new RepoDispControl() { ApplicationId = id, ApplicationName = name, ApplicationVersion = currentVer, ApplicationDescription = desc, ApplicationEnabled = enabled, IsDownloaded = downloaded }; dispControl.ButtonClick += new EventClick(ButtonClick); dispControl.SwitchChecked += new EventChecked(SwitchChecked); dispControl.DownloadPercent = Convert.ToDouble(downloaded); dispControls.Add(id, dispControl); panelRepo.Children.Add(dispControl); id++; } XmlNodeList links = myXmlDocument.SelectNodes("/data/links/link"); foreach (XmlNode link in links) { string name = link["name"].InnerText; string url = link["url"].InnerText; Button linkButton = new Button(); linkButton.Content = name; linkButton.Click += (s, e) => { System.Diagnostics.Process.Start(url); }; buttonsLinksList.Add(url); linkButtonsPanel.Children.Add(linkButton); } customToolsStartId = id + 1; readCustomXML("data/data_custom.xml"); }