Esempio n. 1
0
        /// <summary>
        ///     Adds a new rule to the end of the list and selects it.
        /// </summary>
        private void AddRule()
        {
            HoursPlayedRule newRule = new HoursPlayedRule(GlobalStrings.AutoCatUserScore_NewRuleName, 0, 0);

            ruleList.Add(newRule);
            lstRules.SelectedIndex = lstRules.Items.Count - 1;
        }
Esempio n. 2
0
        private static bool CheckRule(HoursPlayedRule rule, double hours)
        {
            if (!(hours >= rule.MinHours))
            {
                return(false);
            }

            if (hours < rule.MaxHours)
            {
                return(true);
            }

            return(Math.Abs(rule.MaxHours) < 0.01);
        }
Esempio n. 3
0
        /// <summary>
        ///     Moves the specified rule a certain number of spots up or down in the list. Does nothing if the spot would be off
        ///     the list.
        /// </summary>
        /// <param name="mainIndex">Index of the rule to move.</param>
        /// <param name="offset">Number of spots to move the rule. Negative moves up, positive moves down.</param>
        /// <param name="selectMoved">If true, select the moved element afterwards</param>
        private void MoveItem(int mainIndex, int offset, bool selectMoved)
        {
            int alterIndex = mainIndex + offset;

            if (mainIndex < 0 || mainIndex >= lstRules.Items.Count || alterIndex < 0 || alterIndex >= lstRules.Items.Count)
            {
                return;
            }

            HoursPlayedRule mainItem = ruleList[mainIndex];

            ruleList[mainIndex]  = ruleList[alterIndex];
            ruleList[alterIndex] = mainItem;
            if (selectMoved)
            {
                lstRules.SelectedIndex = alterIndex;
            }
        }
Esempio n. 4
0
 public HoursPlayedRule(HoursPlayedRule other)
 {
     Name     = other.Name;
     MinHours = other.MinHours;
     MaxHours = other.MaxHours;
 }
Esempio n. 5
0
 private static bool CheckRule(HoursPlayedRule rule, double hours)
 {
     return(hours >= rule.MinHours && (hours < rule.MaxHours || (int)rule.MaxHours == 0));
 }