Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SectionRowViewModel"/> class.
 /// </summary>
 /// <param name="section"> The <see cref="Models.Section"/> associated to this section row view-model.</param>
 /// <param name="sectionParent">The parent of the section.</param>
 public SectionRowViewModel(Section section, SectionRowViewModel sectionParent)
 {
     this.SectionParent     = sectionParent;
     this.Section           = section;
     this.ContainedSections = new ReactiveList <SectionRowViewModel>();
     this.Name                 = section.Name;
     this.PagePath             = section.PagePath;
     this.AreSubsectionsLoaded = false;
     this.InitializeRowViewIcons();
     this.WhenAnyValue(vm => vm.IsExpanded)
     .ObserveOn(RxApp.MainThreadScheduler)
     .Subscribe(_ => this.ReactOnIsExpandedChange());
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Update the view model from  the new Documentation directory.
        /// </summary>
        public void ReactOnPathDocumentationIndexChange()
        {
            if (this.IsDocumentationLoaded)
            {
                return;
            }

            if (!File.Exists(this.PathDocumentationIndex))
            {
                throw new FileNotFoundException(string.Format("Could not find the index file at the path : '{0}'", this.pathDocumentationIndex));
            }

            this.FirstsRowSections.Clear();
            this.markdownToHtml = new MarkdownToHtml(this.RootAppData);

            var bookFileHandler = new BookFileHandler();

            this.Book = bookFileHandler.DeserializeJsonBook(this.PathDocumentationIndex);

            if (this.UpdateIndexation)
            {
                this.markdownToHtml.TransformTheWholeDocumentationIntoHtml(this.Book, this.PathDocumentationIndex);
            }

            this.DocumentationSearches = new DocumentationSearches(this.PathDocumentationIndex, this.RootAppData, this.Book, this.UpdateIndexation);

            this.BookTitle = this.Book.Title ?? "Table of Contents";

            if (this.Book.Sections.Count >= 1)
            {
                foreach (var section in this.Book.Sections)
                {
                    var sectionViewModel = new SectionRowViewModel(section, null);
                    this.FirstsRowSections.Add(sectionViewModel);
                }
            }

            this.WhenAnyValue(vm => vm.SelectedSection).ObserveOn(RxApp.MainThreadScheduler).Subscribe(_ => this.ReactOnSelectionChange());

            this.LoadBookMainPage();
            this.IsDocumentationLoaded = true;

            this.WhenAnyValue(vm => vm.SearchText)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(_ => this.ReactOnSearchTextChange());

            this.WhenAnyValue(vm => vm.SuggestedPageSelected)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(_ => this.ReactOnSuggestedPageSelected());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create a dummy child if the section represented by this view-model contains subsections. The creation of a dummy child and the inclusion
        /// in the <see cref="ContainedSections"/> list reveal the expandable button of the view associated to this view-model.
        /// This method also choose the appropriate icon to display in the view associated to this view-model.
        /// </summary>
        public void InitializeRowViewIcons()
        {
            if (this.HasSection())
            {
                var dummyChild = new SectionRowViewModel();
                this.ContainedSections.Add(dummyChild);
                this.DisplayedImagePath = FolderImage;
                return;
            }

            if (this.PagePath != null)
            {
                this.DisplayedImagePath = PageImage;
                return;
            }

            this.DisplayedImagePath = null;
        }