public ItemCountSynchronizer(INavigationNode node, EmailFolder folder) { this.node = node; this.folder = folder; CollectionChangedEventManager.AddHandler(folder.Emails, EmailsCollectionChanged); UpdateItemCount(); }
public void Close(INavigationNode toClose) { var viewToReplace = viewsByModel[toClose]; root.Remove(viewToReplace); viewsByModel.Remove(toClose); }
public ItemCountSynchronizer(INavigationNode node, EmailFolder folder) { this.node = node; this.folder = folder; WeakEvent.CollectionChanged.Add(folder.Emails, EmailsCollectionChanged); UpdateItemCount(); }
public void Show(INavigationNode node) { if (CurrentNode == node) { return; } CurrentNode.Dispose(); CurrentNode = node; CurrentNodeChanged?.Invoke(); }
public void Replace <TModel, TParameters>(TParameters parameters, INavigationNode toReplace) where TModel : NavigationNode <TParameters> { toReplace.Terminate(); var viewToReplace = viewsByModel[toReplace]; var(_, view) = instantiateModelAndView <TModel, TParameters>(parameters); new AnchorTemplate(viewToReplace).ApplyTo(view); root.AddOnTopOf(viewToReplace, view); root.Remove(viewToReplace); viewsByModel.Remove(toReplace); }
public void Initialize() { using (var stream = documentService.GetStream(documentPartPath, MediaTypeNames.Text.Xml, FileMode.Open)) { if (stream.Length == 0) { root = new EmailClientRoot(); root.AddEmailAccount(SampleDataProvider.CreateEmailAccount()); foreach (var email in SampleDataProvider.CreateInboxEmails()) { root.Inbox.AddEmail(email); } foreach (var email in SampleDataProvider.CreateSentEmails()) { root.Sent.AddEmail(email); } foreach (var email in SampleDataProvider.CreateDrafts()) { root.Drafts.AddEmail(email); } } else { root = (EmailClientRoot)serializer.Value.ReadObject(stream); } } emailAccountsController.Root = root; INavigationNode node = navigationService.AddNavigationNode("Inbox", ShowInbox, CloseCurrentView, 1, 1); itemCountSychronizers.Add(new ItemCountSynchronizer(node, root.Inbox)); node = navigationService.AddNavigationNode("Outbox", ShowOutbox, CloseCurrentView, 1, 2); itemCountSychronizers.Add(new ItemCountSynchronizer(node, root.Outbox)); node = navigationService.AddNavigationNode("Sent", ShowSentEmails, CloseCurrentView, 1, 3); itemCountSychronizers.Add(new ItemCountSynchronizer(node, root.Sent)); node = navigationService.AddNavigationNode("Drafts", ShowDrafts, CloseCurrentView, 1, 4); itemCountSychronizers.Add(new ItemCountSynchronizer(node, root.Drafts)); node = navigationService.AddNavigationNode("Deleted", ShowDeletedEmails, CloseCurrentView, 1, 5); itemCountSychronizers.Add(new ItemCountSynchronizer(node, root.Deleted)); }
public ItemCountSynchronizer(INavigationNode node, EmailFolder folder) { this.node = node; this.folder = folder; CollectionChangedEventManager.AddHandler((INotifyCollectionChanged)folder.Emails, EmailsCollectionChanged); UpdateItemCount(); }
/// <summary> /// Returns sitemap items from the provided <paramref name="node"/> depending on specified max level of navigation items. /// </summary> /// <typeparam name="T">Type of sitemap nodes to return.</typeparam> /// <param name="node">The navigation node.</param> /// <param name="maxLevel">The max level of navigation items.</param> /// <returns>Sitemap items if <paramref name="node"/> level is less than specified max level, otherwise empty sequence.</returns> public static IEnumerable <T> GetSitemapItems <T>(this INavigationNode node, int maxLevel) where T : class, INavigationNode => (node?.Level ?? int.MaxValue) < maxLevel?node.GetSitemapItems <T>() : Enumerable.Empty <T>();
/// <summary> /// Returns sitemap items from the provided <paramref name="node"/>. /// </summary> /// <typeparam name="T">Type of sitemap nodes to return.</typeparam> /// <param name="node">The navigation node.</param> /// <returns>Sitemap items for the provided <paramref name="node"/>.</returns> public static IEnumerable <T> GetSitemapItems <T>(this INavigationNode node) where T : class, INavigationNode => node.Children <T>(c => !c.HideFromSitemap);
/// <summary> /// Checks if provided <paramref name="node"/> is active for navigation purposes. /// </summary> /// <param name="node">The navigation node.</param> /// <returns><c>true</c> if <paramref name="node"/> is considered as active, otherwise <c>false</c>.</returns> public static bool IsActive(this INavigationNode node) => UmbracoContext.Current?.PublishedContentRequest?.PublishedContent?.Path.ContainsValue(node.Id) ?? false;
/// <summary> /// Checks if provided <paramref name="node"/> contains navigation items. /// </summary> /// <typeparam name="T">Type of the navigation items to check.</typeparam> /// <param name="node">The navigation node.</param> /// <returns><c>true</c> if there are navigation items under the <paramref name="node"/>, otherwise <c>false</c>.</returns> public static bool HasNavigationItems <T>(this INavigationNode node) where T : class, INavigationNode => node.GetNavigationItems <T>().Any();
/// <summary> /// Returns Home Page. /// </summary> /// <typeparam name="T">Type of Home Page node to return.</typeparam> /// <param name="node">The navigation node.</param> /// <returns>Home Page.</returns> public static T GetHome <T>(this INavigationNode node) where T : class, IHomePage => node.GetRoot <IRootNode>().GetHome <T>();
/// <summary> /// Returns <paramref name="node"/> title or <paramref name="node"/> name if title is not specified. /// </summary> /// <param name="node">The navigation node.</param> /// <returns><paramref name="node"/> title or <paramref name="node"/> name if title is not specified.</returns> public static string GetTitle(this INavigationNode node) => !node.Title.IsNullOrEmpty() ? node.Title : node.Name;
public NavigationNode(INavigationNode parent) { this.Parent = parent; }
public void Replace <TModel>(INavigationNode toReplace) where TModel : NavigationNode <Void> { Replace <TModel, Void>(default(Void), toReplace); }
public NavigationModel(INavigationNode initialNode) { Show(initialNode); }
public ItemCountSynchronizer(INavigationNode node, EmailFolder folder) { this.node = node; this.folder = folder; AddWeakEventListener((INotifyCollectionChanged)folder.Emails, EmailsCollectionChanged); UpdateItemCount(); }
/// <summary> /// Returns Site root node. /// </summary> /// <typeparam name="T">Type of Site root node to return.</typeparam> /// <param name="node">The navigation node.</param> /// <returns>Site root node.</returns> public static T GetRoot <T>(this INavigationNode node) where T : class, IRootNode => node?.AncestorOrSelf <T>(1);