public ObservableCollection <PunchCategory> Convert(ObservableCollection <PunchCategory> value, PunchSet parameter)
        {
            PunchSet PS = parameter as PunchSet;

            ObservableCollection <PunchCategory> PCS = value as ObservableCollection <PunchCategory>;
            ObservableCollection <PunchCategory> ret = new ObservableCollection <PunchCategory>(PCS);

            if (PS.Punches.Count == 0)
            {
                foreach (PunchCategory cat in ret)
                {
                    if (cat.PunchType != PunchTypes.StartWork)
                    {
                        ret.Remove(cat);
                    }
                }
                return(ret);
            }
            switch (PS.Punches[PS.Punches.Count - 1].PunchType)
            {
            case PunchTypes.StartWork:
            case PunchTypes.EndBreak:
                foreach (PunchCategory cat in ret)
                {
                    if (cat.PunchType == PunchTypes.StartWork ||
                        cat.PunchType == PunchTypes.EndProject ||
                        cat.PunchType == PunchTypes.EndBreak)
                    {
                        ret.Remove(cat);
                    }
                }
                break;

            case PunchTypes.EndWork:
                foreach (PunchCategory cat in ret)
                {
                    if (cat.PunchType != PunchTypes.StartWork)
                    {
                        ret.Remove(cat);
                    }
                }
                break;

            case PunchTypes.StartBreak:
                foreach (PunchCategory cat in ret)
                {
                    if (cat.PunchType != PunchTypes.EndWork)
                    {
                        ret.Remove(cat);
                    }
                }
                break;

            case PunchTypes.StartProject:
            case PunchTypes.EndProject:
                foreach (PunchCategory cat in ret)
                {
                    if (cat.PunchType == PunchTypes.StartWork ||
                        cat.PunchType == PunchTypes.EndBreak)
                    {
                        ret.Remove(cat);
                    }
                }
                break;
            }

            return(ret);
        }
Пример #2
0
        public ObservableCollection<PunchCategory> Convert(ObservableCollection<PunchCategory> value, PunchSet parameter)
        {
            PunchSet PS = parameter as PunchSet;

                ObservableCollection<PunchCategory> PCS = value as ObservableCollection<PunchCategory>;
                ObservableCollection<PunchCategory> ret = new ObservableCollection<PunchCategory>(PCS);
                if (PS.Punches.Count == 0)
                {
                    foreach (PunchCategory cat in ret)
                    {
                        if (cat.PunchType != PunchTypes.StartWork)
                        {
                            ret.Remove(cat);
                        }
                    }
                    return ret;
                }
                switch (PS.Punches[PS.Punches.Count - 1].PunchType)
                {
                    case PunchTypes.StartWork:
                    case PunchTypes.EndBreak:
                        foreach (PunchCategory cat in ret)
                        {
                            if (cat.PunchType == PunchTypes.StartWork ||
                                cat.PunchType == PunchTypes.EndProject ||
                                cat.PunchType == PunchTypes.EndBreak)
                            {
                                ret.Remove(cat);
                            }
                        }
                        break;
                    case PunchTypes.EndWork:
                        foreach (PunchCategory cat in ret)
                        {
                            if (cat.PunchType != PunchTypes.StartWork)
                            {
                                ret.Remove(cat);
                            }
                        }
                        break;
                    case PunchTypes.StartBreak:
                        foreach (PunchCategory cat in ret)
                        {
                            if (cat.PunchType != PunchTypes.EndWork)
                            {
                                ret.Remove(cat);
                            }
                        }
                        break;
                    case PunchTypes.StartProject:
                    case PunchTypes.EndProject:
                        foreach (PunchCategory cat in ret)
                        {
                            if (cat.PunchType == PunchTypes.StartWork ||
                                cat.PunchType == PunchTypes.EndBreak)
                            {
                                ret.Remove(cat);
                            }
                        }
                        break;
                }

            return ret;
        }