예제 #1
0
 public ItemCountSynchronizer(INavigationNode node, EmailFolder folder)
 {
     this.node   = node;
     this.folder = folder;
     CollectionChangedEventManager.AddHandler(folder.Emails, EmailsCollectionChanged);
     UpdateItemCount();
 }
예제 #2
0
        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();
 }
예제 #4
0
        public void Show(INavigationNode node)
        {
            if (CurrentNode == node)
            {
                return;
            }

            CurrentNode.Dispose();
            CurrentNode = node;
            CurrentNodeChanged?.Invoke();
        }
예제 #5
0
        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);
        }
예제 #6
0
        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));
        }
예제 #7
0
 public ItemCountSynchronizer(INavigationNode node, EmailFolder folder)
 {
     this.node = node;
     this.folder = folder;
     CollectionChangedEventManager.AddHandler((INotifyCollectionChanged)folder.Emails, EmailsCollectionChanged);
     UpdateItemCount();
 }
예제 #8
0
 /// <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>();
예제 #9
0
 /// <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);
예제 #10
0
 /// <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;
예제 #11
0
 /// <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();
예제 #12
0
 /// <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>();
예제 #13
0
 /// <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;
예제 #14
0
 public NavigationNode(INavigationNode parent)
 {
     this.Parent = parent;
 }
예제 #15
0
 public void Replace <TModel>(INavigationNode toReplace)
     where TModel : NavigationNode <Void>
 {
     Replace <TModel, Void>(default(Void), toReplace);
 }
예제 #16
0
 public NavigationModel(INavigationNode initialNode)
 {
     Show(initialNode);
 }
예제 #17
0
 public ItemCountSynchronizer(INavigationNode node, EmailFolder folder)
 {
     this.node = node;
     this.folder = folder;
     AddWeakEventListener((INotifyCollectionChanged)folder.Emails, EmailsCollectionChanged);
     UpdateItemCount();
 }
예제 #18
0
 /// <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);