private void SetItemsToCache(string cacheKey, NavigationList cachedObject, double cacheExpiration)
        {
            ObjectCache     cache  = MemoryCache.Default;
            CacheItemPolicy policy = new CacheItemPolicy();

            policy.AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(cacheExpiration);
            cache.Set(cacheKey, cachedObject, policy);
        }
示例#2
0
        private static async Task ProcessMenuPool()
        {
            MenuPool.ProcessMenus();

            if (MenuPool.ToList().Count == 0 && Camera != null)
            {
                Camera = null;
                ShowShopMenu();
            }

            if (Game.IsControlJustPressed(0, (Control)244) || Game.IsDisabledControlJustPressed(0, (Control)244))   //M
            {
                ShowInGameMenu();
            }

            if (Game.IsControlJustPressed(0, (Control)174) || Game.IsDisabledControlJustPressed(0, (Control)174))   // left
            {
                if (User.GetStatusType() != StatusTypes.Spectator)
                {
                    return;
                }

                var list = new NavigationList <Player>();
                list.AddRange(new PlayerList().Where(p => !p.IsDead).Where(p => !p.IsInvincible));
                try
                {
                    User.StartSpec(list.MovePrevious);
                }
                catch (Exception e)
                {
                    Debug.WriteLine($"{list.Count} | {e}");
                    User.StartSpec(list.First());
                }
            }
            else if (Game.IsControlJustPressed(0, (Control)175) || Game.IsDisabledControlJustPressed(0, (Control)175))   // right
            {
                if (User.GetStatusType() != StatusTypes.Spectator)
                {
                    return;
                }
                var list = new NavigationList <Player>();
                list.AddRange(new PlayerList().Where(p => !p.IsDead).Where(p => !p.IsInvincible));
                try
                {
                    User.StartSpec(list.MoveNext);
                }
                catch (Exception e)
                {
                    Debug.WriteLine($"{list.Count} | {e}");
                    User.StartSpec(list.Last());
                }
            }
        }
 public void NavigateOrOpenNavigationList(IReadOnlyList <INavigationToken> navigations)
 {
     if (navigations.Count == 1)
     {
         navigations[0].Navigate();
     }
     else if (navigations.Count > 1)
     {
         NavigationList.UpdateNavigationList(navigations);
     }
     else
     {
         Error.ShowWarningMessage("Cannot navigate to the symbol under the cared");
     }
 }
        /// <summary>
        /// Adds a new module to the navigation view. Called by the <see cref="ModuleNavigator"/>.
        /// </summary>
        /// <param name="moduleSettings">Module settings.</param>
        public void AddModule(ModuleSettings moduleSettings)
        {
            if (moduleSettings == null)
            {
                throw new ArgumentNullException(nameof(moduleSettings));
            }

            var navigationPanelItem = new NavigationPanelItem
            {
                NavigationPanelItemName = moduleSettings.ModuleName,
                ImageLocation           = moduleSettings.ModuleImagePath
            };

            foreach (ModuleGroup moduleGroup in moduleSettings.ModuleGroups)
            {
                var navigationList = new NavigationList {
                    NavigationListName = moduleGroup.ModuleGroupName
                };

                foreach (ModuleGroupItem moduleGroupItem in moduleGroup.ModuleGroupItems)
                {
                    var navigationListItem = new NavigationListItem
                    {
                        ItemName      = moduleGroupItem.ModuleGroupItemName,
                        ImageLocation = moduleGroupItem.ModuleGroupItemImagePath
                    };

                    OnRegisterNavigation(navigationListItem);

                    navigationList.NavigationListItems.Add(navigationListItem);

                    var navigationSettings = new NavigationSettings
                    {
                        Title = moduleGroupItem.TargetViewTitle,
                        View  = moduleGroupItem.TargetView
                    };

                    string navigationKey = $"{navigationPanelItem.NavigationPanelItemName}.{navigationList.NavigationListName}.{navigationListItem.ItemName}";

                    navigationListItem.Tag = navigationKey;
                    NavigationSettingsList.Add(navigationKey, navigationSettings);
                }

                navigationPanelItem.NavigationList.Add(navigationList);
            }

            NavigationPanelItems.Add(navigationPanelItem);
        }
        /// <summary>
        /// Get all navigation items
        /// </summary>
        /// <param name="getFromCache">Whether to get items from cache or not. Default is true.</param>
        public NavigationList GetItems(bool getFromCache = true)
        {
            NavigationList = new NavigationList();

            if (getFromCache)
            {
                var cacheKey = CACHE_KEY_PREFIX + Content.Key;
                NavigationList = GetItemsFromCache(cacheKey);
            }
            else
            {
                NavigationList = GetChildItems(Content);
            }

            return(NavigationList);
        }
示例#6
0
        private void Scroll(object sender, MouseEventArgs e)
        {
            if (NavigationList.Items.Count == 0)
            {
                return;
            }

            Point  p      = e.GetPosition(NavigationScrollBarBorder);
            double height = NavigationScrollBarBorder.ActualHeight;

            double precent = p.Y / height;

            int idx = (int)(NavigationList.Items.Count * precent);

            idx = NavigationList.Items.Count == idx ? idx - 1 : idx;
            NavigationList.ScrollIntoView(NavigationList.Items[idx]);
        }
示例#7
0
        /// <summary>
        /// Adds a new module to the navigation view. Called by the <see cref="ModuleNavigator"/>.
        /// </summary>
        /// <param name="moduleSettings">Module settings.</param>
        public void AddModule(ModuleSettings moduleSettings)
        {
            var navigationPanelItem = new NavigationPanelItem
            {
                NavigationPanelItemName = moduleSettings.ModuleName,
                ImageLocation           = moduleSettings.ModuleImagePath
            };

            foreach (ModuleGroup moduleGroup in moduleSettings.ModuleGroups)
            {
                var navigationList = new NavigationList {
                    NavigationListName = moduleGroup.ModuleGroupName
                };

                foreach (ModuleGroupItem moduleGroupItem in moduleGroup.ModuleGroupItems)
                {
                    var navigationListItem = new NavigationListItem
                    {
                        ItemName      = moduleGroupItem.ModuleGroupItemName,
                        ImageLocation = moduleGroupItem.ModuleGroupItemImagePath
                    };

                    OnRegisterNavigation(navigationListItem);

                    navigationList.NavigationListItems.Add(navigationListItem);

                    var navigationSettings = new NavigationSettings
                    {
                        Title = moduleGroupItem.TargetViewTitle,
                        View  = moduleGroupItem.TargetView
                    };

                    string navigationKey = string.Format("{0}.{1}.{2}",
                                                         navigationPanelItem.NavigationPanelItemName,
                                                         navigationList.NavigationListName,
                                                         navigationListItem.ItemName);

                    navigationListItem.Tag = navigationKey;
                    NavigationSettingsList.Add(navigationKey, navigationSettings);
                }

                navigationPanelItem.NavigationList.Add(navigationList);
            }

            NavigationPanelItems.Add(navigationPanelItem);
        }
        private NavigationList GetItemsFromCache(string cacheKey)
        {
            ObjectCache cache        = MemoryCache.Default;
            var         cachedObject = new NavigationList();

            if (cache.Contains(cacheKey))
            {
                cachedObject = (NavigationList)cache[cacheKey];
            }
            else
            {
                cachedObject = GetChildItems(Content);
                SetItemsToCache(cacheKey, cachedObject, CacheExpiration);
            }

            return(cachedObject);
        }
        public List <NavigationList> GetSubNavigationList(dynamic page)
        {
            List <NavigationList> navList = null;
            var subPages = page.Children.Where("Visible");

            if (subPages != null && subPages.Any() && subPages.Count() > 0)
            {
                navList = new List <NavigationList>();
                foreach (var subPage in subPages)
                {
                    var listItem = new NavigationList(new NavigationLinkInfo(subPage.Url, subPage.Name))
                    {
                        NavItems = GetSubNavigationList(subPage)
                    };
                    navList.Add(listItem);
                }
            }
            return(navList);
        }
        private NavigationList GetChildItems(IPublishedContent parentContent)
        {
            var childItems = new NavigationList();

            childItems.Items = new List <NavigationListItem>();

            foreach (var childContent in parentContent.Children.Where(x => x.IsVisible()))
            {
                childItems.Items.Add(new NavigationListItem
                {
                    Id      = childContent.Id,
                    Name    = childContent.Name,
                    Url     = childContent.Url,
                    Content = childContent,
                    List    = childContent.Children.Any() ? GetChildItems(childContent) : new NavigationList()
                });
            }

            return(childItems);
        }
示例#11
0
 protected bool DisplayModuleList(CategorySettings category)
 {
     return(NavigationList.Intersect(category.Modules).Any());
 }
示例#12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MXApplication"/> class.
 /// </summary>
 protected MXApplication()
 {
     NavigationMap  = new NavigationList();
     NavigateOnLoad = string.Empty;
 }