Example #1
0
        public static void PushRecentCondition(Condition c)
        {
            FavoriteCondition f = new FavoriteCondition(c);

            if (!HasFavorite(f))
            {
                int index = RecentIndex(f);

                if (index == -1)
                {
                    //push back
                    List <FavoriteCondition> list = new List <FavoriteCondition>();
                    list.Add(f);
                    for (int i = 0; i < _RecentCondtions.Count && i < RecentLength - 1; i++)
                    {
                        list.Add(_RecentCondtions[i]);
                    }
                    _RecentCondtions = list;
                }
                else if (index > 0)
                {
                    _RecentCondtions.RemoveAt(index);
                    _RecentCondtions.Insert(0, f);
                }
            }
            SaveRecentConditions();
        }
Example #2
0
 public static Condition FromFavorite(FavoriteCondition fc)
 {
     if (fc.Type == ConditionType.Custom)
     {
         return(_CustomConditions.FirstOrDefault(a => String.Compare(a.Name, fc.Name, true) == 0));
     }
     else
     {
         return(_Conditions.FirstOrDefault(a => (String.Compare(a.Name, fc.Name, true) == 0) &&
                                           (fc.Type == a.Type)));
     }
 }
Example #3
0
        public static int RecentIndex(FavoriteCondition fc)
        {
            for (int i = 0; i < _RecentCondtions.Count; i++)
            {
                FavoriteCondition r = _RecentCondtions[i];
                if (String.Compare(r.Name, fc.Name, true) == 0 && r.Type == fc.Type)
                {
                    return(i);
                }
            }

            return(-1);
        }
Example #4
0
 public static bool HasFavorite(FavoriteCondition fc)
 {
     return(_FavoriteConditions.FirstOrDefault(a => String.Compare(a.Name, fc.Name, true) == 0 && a.Type == fc.Type) != null);
 }