private void InitializeData(Boolean refreshTreeView) { SetStatusMessage("Loading"); // // Read from Database // _allData = Data.Host.LoadAll(); SetStatusMessage("Loaded"); // // Update the treeview // if (refreshTreeView) { //Set selected item TreeModel.Items[0].IsSelected = true; RaisePropertyChanged("TreeModel"); SelectedItemChanged(new RoutedPropertyChangedEventArgs <object>(null, TreeModel.Items[0])); } // // Update articles // if (_selectedNode != null) { SimpleTreeNodeViewModel tvm = (SimpleTreeNodeViewModel)_selectedNode; if (tvm.Node is Model.Feed) { SetStatusMessage("Updating Articles (feed)... "); Model.Feed selectedFeed = (Model.Feed)tvm.Node; // Find the feed and add the Articles foreach (Host h in _allData) { Feed f = h.Feeds.FirstOrDefault(el => el.Location.Equals(selectedFeed.Location)); if (f != null) { Articles.AddMissing(f.Articles, new ArticleEqualityComparer(), _uiContext); } } } else if (tvm.Node is Model.Host) { SetStatusMessage("Updating Articles (host)... "); Model.Host selectedHost = (Model.Host)tvm.Node; // Find the host and add the Articels Model.Host h = _allData.FirstOrDefault(el => el.Location.Equals(selectedHost.Location)); foreach (Model.Feed feed in h.Feeds) { Articles.AddMissing(feed.Articles, new ArticleEqualityComparer(), _uiContext); } } else { SetStatusMessage("Updating Articles (article)... "); foreach (Model.Host h in _allData) { foreach (Model.Feed feed in h.Feeds) { Articles.AddMissing(feed.Articles, new ArticleEqualityComparer(), _uiContext); } } } } if (refreshTreeView) { SetStatusMessage("Refreshing Article list"); SetSortOrder(); } SetStatusMessage("Ready"); }