Exemplo n.º 1
0
        private void PopulateSortView()
        {
            if (DefaultSorts == null)
            {
                DefaultSorts = new Sort[]
                {
                    new Sort(new UIImage(HEROsMod.instance.GetTexture("Images/sortItemID"))
                    {
                        Tooltip = HeroText("SortName.ItemID")
                    }, (x, y) => x.type.CompareTo(y.type)),
                    new Sort(new UIImage(HEROsMod.instance.GetTexture("Images/sortValue"))
                    {
                        Tooltip = HeroText("SortName.Value")
                    }, (x, y) => x.value.CompareTo(y.value)),
                    new Sort(new UIImage(HEROsMod.instance.GetTexture("Images/sortAZ"))
                    {
                        Tooltip = HeroText("SortName.Alphabetical")
                    }, (x, y) => x.Name.CompareTo(y.Name)),
                };
            }
            List <Sort> sorts = DefaultSorts.ToList();

            if (SelectedCategory != null)
            {
                if (SelectedCategory.ParentCategory != null)
                {
                    foreach (var item in SelectedCategory.ParentCategory.Sorts)
                    {
                        sorts.Add(item);
                    }
                }
                foreach (var item in SelectedCategory.Sorts)
                {
                    sorts.Add(item);
                }
            }

            AvailableSorts = sorts.ToArray();

            _sortView.RemoveAllChildren();
            _sortView.X = _spacer.X + _spacer.Width;
            float xPos = 0;

            for (int i = 0; i < AvailableSorts.Length; i++)
            {
                UIImage button = AvailableSorts[i].button;
                button.Width = 20;
                int x = i / 1;
                int y = i % 1;
                button.X = Spacing + x * (button.Width + Spacing);
                button.Y = Spacing + y * (button.Height + Spacing);
                xPos     = button.X + button.Width + Spacing;
                _sortView.AddChild(button);
            }
            _sortView.Width = xPos;
        }
Exemplo n.º 2
0
        public MvcHtmlString GetSortsJson()
        {
            if (DefaultSorts == null)
            {
                return(MvcHtmlString.Create("null"));
            }

            var output = DefaultSorts.Select(x => new List <object> {
                x.iSortCol, x.sSortDir
            });
            var serializer = new JavaScriptSerializer();
            var sb         = new StringBuilder();

            serializer.Serialize(output, sb);
            return(MvcHtmlString.Create(sb.ToString()));
        }
Exemplo n.º 3
0
        private void PopulateSortView()
        {
            List <Sort> sorts = DefaultSorts.ToList();

            if (SelectedCategory != null)
            {
                if (SelectedCategory.ParentCategory != null)
                {
                    foreach (var item in SelectedCategory.ParentCategory.Sorts)
                    {
                        sorts.Add(item);
                    }
                }
                foreach (var item in SelectedCategory.Sorts)
                {
                    sorts.Add(item);
                }
            }

            AvailableSorts = sorts.ToArray();

            _sortView.RemoveAllChildren();
            _sortView.X = _spacer.X + _spacer.Width;
            float xPos = 0;

            for (int i = 0; i < AvailableSorts.Length; i++)
            {
                UIImage button = AvailableSorts[i].button;
                button.Width = 20;
                int x = i / 1;
                int y = i % 1;
                button.X = Spacing + x * (button.Width + Spacing);
                button.Y = Spacing + y * (button.Height + Spacing);
                xPos     = button.X + button.Width + Spacing;
                _sortView.AddChild(button);
            }
            _sortView.Width = xPos;
        }