using System.Collections.Generic; using System.Collections.ObjectModel; namespace VersOne.Epub.WpfDemo.ViewModels { /// /// View model for a navigation item (which can be a link or a header). /// public class NavigationItemViewModel : ViewModel { private bool isTreeItemExpanded; /// /// Initializes a new instance of the class for a navigation header. /// /// The title of the navigation header. /// A list of the nested navigation items. public NavigationItemViewModel(string title, IEnumerable nestedItems) { IsLink = false; Title = title; NestedItems = new ObservableCollection(nestedItems); isTreeItemExpanded = false; } /// /// Initializes a new instance of the class for a navigation link. /// /// The title of the navigation link. /// The absolute path for the content file in the EPUB archive referenced by this link. /// An optional anchor inside the HTML content file that needs to be scrolled to once the content is fully loaded. /// A list of the nested navigation items. public NavigationItemViewModel(string title, string filePathInEpubArchive, string anchor, IEnumerable nestedItems) { IsLink = true; FilePathInEpubArchive = filePathInEpubArchive; Anchor = anchor; Title = title; NestedItems = new ObservableCollection(nestedItems); isTreeItemExpanded = false; } /// /// Gets a value indicating whether this navigation item is a clickable link (as opposed to a non-clickable navigation header). /// public bool IsLink { get; } /// /// Gets the title of the navigation item (which is either the text of the header or the title of the navigation link). /// public string Title { get; } /// /// Gets the absolute path for the content file in the EPUB archive referenced by this navigation item (used only when the value of the is true). /// public string FilePathInEpubArchive { get; } /// /// Gets an optional anchor inside the HTML content file that needs to be scrolled to once the content is fully loaded. /// public string Anchor { get; } /// /// Gets a collection of the nested navigation items. /// public ObservableCollection NestedItems { get; } /// /// Gets or sets a value indicating whether the tree node associated with this navigation item is expanded or not (used only when this navigation item has nested items). /// public bool IsTreeItemExpanded { get { return isTreeItemExpanded; } set { isTreeItemExpanded = value; NotifyPropertyChanged(); } } } }