public static ObservableCollection<WebPage> GetWebPages() { ObservableCollection<WebPage> webPages = new ObservableCollection<WebPage>(); // Parse the WebPages section of the settings file XDocument settingsFile = XDocument.Load(_settingsXmlFile); IEnumerable<XElement> settingsWebPages = settingsFile.Root.Descendants("WebPages"); foreach (XElement webPage in settingsWebPages.Descendants("WebPage")) { // Create new WebPage object from xml file WebPage newWebPage = new WebPage { Name = webPage.Descendants("Name").FirstOrDefault().Value, RootUrl = webPage.Descendants("RootUrl").FirstOrDefault().Value }; // Get the variable XElement variable = webPage.Descendants("Variable").FirstOrDefault(); newWebPage.Variable = new QueryStringVariable { FriendlyName = variable.Descendants("FriendlyName").FirstOrDefault().Value, Key = variable.Descendants("Key").FirstOrDefault().Value, Value = "" }; // Add the browser to the collection webPages.Add(newWebPage); } return webPages; }
public MainWindowViewModel() { // Register the launch website command this.LaunchWebsiteCommand = new RelayCommand(this.LaunchWebsite, () => _launchWithBrowser.Issues == null); this.SetSearchCriteriaCommand = new RelayCommand<SavedLaunch>(this.SetSearch); RecentSearches = new ObservableCollection<SavedLaunch>(); Browsers = AppSettings.GetBrowsers(); _launchWithBrowser = Browsers.First(); WebPages = AppSettings.GetWebPages(); _launchWebPage = WebPages.First(); Launch.WebPage = WebPages.First(); }