Пример #1
0
 protected internal void OnClick(int index, string name, MouseEventArgs _)
 {
     if (Conditions[index] is List <Catalog.Models.Intro> model && model.Where(o => string.IsNullOrEmpty(o.Theme) is false) is IEnumerable <Catalog.Models.Intro> list)
     {
         IsSort[name]      = IsSort.ContainsKey(name) && IsSort[name] is false;
         Conditions[index] = (name switch
         {
             nameof(Catalog.Models.Intro.Code) => IsSort[name] ? list.OrderBy(o => o.Code) : list.OrderByDescending(o => o.Code),
             nameof(Catalog.Models.Intro.Name) => IsSort[name] ? list.OrderBy(o => o.Name) : list.OrderByDescending(o => o.Name),
             nameof(Interface.KRX.Line.Week) => IsSort[name] ? list.OrderBy(o => o.Inclination[0]) : list.OrderByDescending(o => o.Inclination[0]),
             nameof(Interface.KRX.Line.Month) => IsSort[name] ? list.OrderBy(o => o.Inclination[1]) : list.OrderByDescending(o => o.Inclination[1]),
             nameof(Interface.KRX.Line.Quarter) => IsSort[name] ? list.OrderBy(o => o.Inclination[2]) : list.OrderByDescending(o => o.Inclination[2]),
             nameof(Interface.KRX.Line.Semiannual) => IsSort[name] ? list.OrderBy(o => o.Inclination[3]) : list.OrderByDescending(o => o.Inclination[3]),
             nameof(Interface.KRX.Line.Annual) => IsSort[name] ? list.OrderBy(o => o.Inclination[^ 1]) : list.OrderByDescending(o => o.Inclination[^ 1]),
Пример #2
0
        protected internal void OnClick(string name, int index, MouseEventArgs _)
        {
            if (Conditions[index] is List <Catalog.Models.Intro> model)
            {
                IsSort[name] = IsSort.ContainsKey(name) && IsSort[name] is false;
                List <Catalog.Models.Intro> list;

                switch (name)
                {
                case nameof(Catalog.Models.Intro.Code):
                    list = (IsSort[name] ? model.OrderBy(o => o.Code) : model.OrderByDescending(o => o.Code)).ToList();
                    break;

                case nameof(Catalog.Models.Intro.Name):
                    list = (IsSort[name] ? model.OrderBy(o => o.Name) : model.OrderByDescending(o => o.Name)).ToList();
                    break;

                case nameof(Catalog.Models.Intro.Price):
                    list = new List <Catalog.Models.Intro>();

                    if (IsSort[name])
                    {
                        foreach (var code in from o in Sort orderby o.Value.Item1 select o.Key)
                        {
                            if (string.IsNullOrEmpty(code) is false && model.Find(o => o.Code.Equals(code)) is Catalog.Models.Intro ps)
                            {
                                list.Add(ps);
                            }
                        }
                    }
                    else
                    {
                        foreach (var code in from o in Sort orderby o.Value.Item1 descending select o.Key)
                        {
                            if (string.IsNullOrEmpty(code) is false && model.Find(o => o.Code.Equals(code)) is Catalog.Models.Intro ps)
                            {
                                list.Add(ps);
                            }
                        }
                    }

                    break;

                default:
                    list = new List <Catalog.Models.Intro>();

                    if (IsSort[name])
                    {
                        foreach (var code in from o in Sort orderby o.Value.Item2 select o.Key)
                        {
                            if (string.IsNullOrEmpty(code) is false && model.Find(o => o.Code.Equals(code)) is Catalog.Models.Intro ps)
                            {
                                list.Add(ps);
                            }
                        }
                    }
                    else
                    {
                        foreach (var code in from o in Sort orderby o.Value.Item2 descending select o.Key)
                        {
                            if (string.IsNullOrEmpty(code) is false && model.Find(o => o.Code.Equals(code)) is Catalog.Models.Intro ps)
                            {
                                list.Add(ps);
                            }
                        }
                    }

                    break;
                }
                Conditions[index] = list;
            }
        }