/// <summary> /// Adds a new rule to the end of the list and selects it. /// </summary> private void AddRule() { HowLongToBeatRule newRule = new HowLongToBeatRule(GlobalStrings.AutoCatUserScore_NewRuleName, 0, 0, (TimeType)cmbTimeType.SelectedItem); ruleList.Add(newRule); lstRules.SelectedIndex = lstRules.Items.Count - 1; }
private static bool CheckRule(HowLongToBeatRule rule, float hltbMain, float hltbExtras, float hltbCompletionist) { float hours; switch (rule.TimeType) { case TimeType.Main: hours = hltbMain; break; case TimeType.Extras: hours = hltbExtras; break; case TimeType.Completionist: hours = hltbCompletionist; break; default: throw new ArgumentOutOfRangeException(); } if (hours == 0.0f) { return(false); } return(hours >= rule.MinHours && (hours <= rule.MaxHours || rule.MaxHours == 0.0f)); }
/// <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; } HowLongToBeatRule mainItem = ruleList[mainIndex]; ruleList[mainIndex] = ruleList[alterIndex]; ruleList[alterIndex] = mainItem; if (selectMoved) { lstRules.SelectedIndex = alterIndex; } }