示例#1
0
        public FinanceFilterItemViewModel(StatisticTypeEnum statisticType)
        {
            _model   = StatisticTypeManagement.Instance.StatisticTypeCollection.Where(s => s.StatisticType == statisticType).First();
            ItemName = _model.ShownText;
            switch (_model.Catogery)
            {
            case StatisticCategoryEnum.Income:
                BorderColor = GlobalVariables.IncomeColor;
                break;

            case StatisticCategoryEnum.Outcome:
                BorderColor = GlobalVariables.ExpenseColor;
                break;
            }
            if (statisticType == StatisticTypeEnum.Diff)
            {
                BorderColor = GlobalVariables.SecondaryColor;
            }
            if (statisticType == StatisticTypeEnum.Capital)
            {
                BorderColor = GlobalVariables.MainColor;
            }
            Init();
        }
示例#2
0
        private void OnFilterItemClickedEvent(StatisticTypeModel statisticType, bool isSelected)
        {
            if (isSelected)
            {
                if (_allCollection.Contains(statisticType.StatisticType))
                {
                    _detailStatistic.Clear();
                    if (statisticType.StatisticType == StatisticTypeEnum.Capital)
                    {
                        AllIncome.ChangeSelectionState(false);
                        AllOutcome.ChangeSelectionState(false);
                        Diff.ChangeSelectionState(false);
                        _allStatistic.Clear();
                    }
                    else
                    {
                        Capital.ChangeSelectionState(false);
                        int capitalIndex = _allStatistic.IndexOf(_allStatistic.Where(s => s.StatisticType == StatisticTypeEnum.Capital).FirstOrDefault());
                        if (capitalIndex >= 0)
                        {
                            _allStatistic.RemoveAt(capitalIndex);
                        }
                    }

                    _allStatistic.Add(statisticType);

                    foreach (FilterItemViewModel item in IncomeItems)
                    {
                        item.ChangeSelectionState(false);
                    }
                    foreach (FilterItemViewModel item in OutcomeItems)
                    {
                        item.ChangeSelectionState(false);
                    }
                }
                else
                {
                    _allStatistic.Clear();
                    _detailStatistic.RemoveAll(s => s.Catogery != statisticType.Catogery);
                    _detailStatistic.Add(statisticType);

                    AllIncome.ChangeSelectionState(false);
                    AllOutcome.ChangeSelectionState(false);
                    Diff.ChangeSelectionState(false);
                    Capital.ChangeSelectionState(false);
                    foreach (FilterItemViewModel item in (statisticType.Catogery == StatisticCategoryEnum.Income ? OutcomeItems : IncomeItems))
                    {
                        item.ChangeSelectionState(false);
                    }
                }
            }
            else
            {
                if (_allCollection.Contains(statisticType.StatisticType))
                {
                    _allStatistic.Remove(statisticType);
                }
                else
                {
                    _detailStatistic.Remove(statisticType);
                }
            }
            RaiseFilterItemsChangedEvent();
        }