Esempio n. 1
0
        public State(List <EntryData> entryDatas, Languages languages)
        {
            Cargo = new SortedObservableCounter((a, b) => string.Compare(languages.Translate(a.Key), languages.Translate(b.Key), StringComparison.InvariantCultureIgnoreCase));
            languages.PropertyChanged += (o, e) => Cargo.RefreshSort();

            this.entryDatas = entryDatas;
            LoadBaseData();
        }
Esempio n. 2
0
        public State(List <EntryData> entryDatas, ILanguage languages, string comparer)
        {
            comparers = new Dictionary <string, Comparer>()
            {
                [NAME_COMPARER]  = (a, b) => string.Compare(languages.Translate(a.Key), languages.Translate(b.Key), StringComparison.InvariantCultureIgnoreCase),
                [COUNT_COMPARER] = (a, b) => b.Value.Count.CompareTo(a.Value.Count)
            };

            Cargo = new SortedObservableCounter(comparers[comparer]);
            languages.PropertyChanged += (o, e) => Cargo.RefreshSort();

            this.entryDatas = entryDatas;
            LoadBaseData();
        }
Esempio n. 3
0
        public StateCargo(List <EntryData> entryDatas, List <Equipment> equipments, ILanguage languages, string comparer)
        {
            comparers = new Dictionary <string, Comparer>
            {
                [NAME_COMPARER]   = (a, b) => string.Compare(languages.Translate(a.Key), languages.Translate(b.Key), StringComparison.InvariantCultureIgnoreCase),
                [COUNT_COMPARER]  = (a, b) => b.Value.Count.CompareTo(a.Value.Count),
                [RARITY_COMPARER] = (a, b) => ((int)a.Value.Data.Rarity).CompareTo((int)b.Value.Data.Rarity)
            };

            Ingredients = new SortedObservableCounter(comparers[comparer]);
            languages.PropertyChanged += (o, e) => Ingredients.RefreshSort();

            this.entryDatas = entryDatas;
            this.equipments = equipments;
            LoadBaseData();
        }
Esempio n. 4
0
        public State(List <EntryData> entryDatas, ILanguage languages, string comparer)
        {
            comparers = new Dictionary <string, Comparer>()
            {
                [NAME_COMPARER]       = (a, b) => string.Compare(languages.Translate(a.Key), languages.Translate(b.Key), StringComparison.InvariantCultureIgnoreCase),
                [COUNT_COMPARER]      = (a, b) => b.Value.Count.CompareTo(a.Value.Count),
                [THRESHOLDS_COMPARER] = (a, b) =>
                {
                    if (a.Value.Threshold.HasValue && !b.Value.Threshold.HasValue)
                    {
                        return(-1);
                    }

                    if (!a.Value.Threshold.HasValue && b.Value.Threshold.HasValue)
                    {
                        return(1);
                    }

                    if (a.Value.Threshold.HasValue && b.Value.Threshold.HasValue)
                    {
                        return
                            ((b.Value.Count - b.Value.Threshold.Value).CompareTo(a.Value.Count -
                                                                                 a.Value
                                                                                 .Threshold
                                                                                 .Value));
                    }

                    return(comparers[COUNT_COMPARER](a, b));
                }
            };

            Cargo = new SortedObservableCounter(comparers[comparer]);
            languages.PropertyChanged += (o, e) => Cargo.RefreshSort();

            this.entryDatas = entryDatas;
            LoadBaseData();
        }