/// <summary>
        ///     Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            LoadUrlCommand = new RelayCommand(OnLoadUrl);
            ParseUrlCommand = new RelayCommand(OnParseUrl, () => !string.IsNullOrEmpty(URL));
            ExportCommand = new RelayCommand(OnExport);
            GetUrlsCommand = new RelayCommand(OnGetUrls);

            _catalogObservableList = new ObservableCollection<CatalogNodeViewModel>();
            CatalogCollectionView = new ListCollectionView(_catalogObservableList);

            if (IsInDesignMode)
            {
                // Code runs in Blend --> create design time data.
                URL = "http://hqfz.cnblgos.com";
                CnBlogName = "hqfz";
                var catalog = new CatalogNodeViewModel();
                catalog.CurrentEntity.Title = "Catalog1";
                var article = new ArticleViewModel();
                article.CurrentEntity.Title = "Article1";
                catalog.AddArticle(article);

                _catalogObservableList.Add(catalog);
            }
            else
            {
                // Code runs "for real"
                URL = "http://www.cnblogs.com/artech/default.html?page=1";
                CnBlogName = "artech";
            }
        }
 internal void AddArticle(ArticleViewModel articleViewModel)
 {
     _articlesObservableList.Add(articleViewModel);
 }
        private async void OnParseUrl()
        {
            _catalogObservableList.Clear();

            var scheduler = TaskScheduler.FromCurrentSynchronizationContext();
            Content = "Analyzing...";
            await Task.Run(() =>
            {
                IBlogProcess blogProcess = new CnblogProcess();
                return blogProcess.ParseCatalogs(CnBlogName);
            }).ContinueWith(
                t =>
                {
                    Content = "Create tree...";

                    foreach (var catalog in t.Result)
                    {
                        var catalogViewModel = new CatalogNodeViewModel(catalog);

                        foreach (var article in catalog.Articles)
                        {
                            var articleViewModel = new ArticleViewModel(article);
                            catalogViewModel.AddArticle(articleViewModel);
                        }

                        _catalogObservableList.Add(catalogViewModel);
                    }

                    Content = "Analyzing is finished";
                }, scheduler);
        }
 internal void AddArticle(ArticleViewModel articleViewModel)
 {
     _articlesObservableList.Add(articleViewModel);
 }