private void applyUncheckLogic(StateClick click, FilterValueState[] states) { switch (click.ClickedState) { case FilterValueState.RequiredSome: case FilterValueState.Required: states[click.ButtonIndex] = FilterValueState.Ignored; break; case FilterValueState.Ignored: if (EnableCostBehavior && click.MouseButton == MouseButtons.Left) { applyUncheckCostLogic(click, states); } else if (EnableRequiringSome) { states[click.ButtonIndex] = FilterValueState.Ignored; } else { states[click.ButtonIndex] = FilterValueState.Prohibited; } break; case FilterValueState.Prohibited: states[click.ButtonIndex] = FilterValueState.Ignored; break; } }
private void applyUncheckCostLogic(StateClick click, FilterValueState[] states) { bool allAllowed = true; bool allProhibited = true; var i = click.ButtonIndex; for (int j = 0; j < states.Length; j++) { if (i == j) { continue; } allProhibited &= states[j] == FilterValueState.Prohibited; if (isCostNeutral(j)) { continue; } allAllowed &= states[j] == FilterValueState.Ignored; } if (allAllowed && !isCostNeutral(i)) { // Оставить разрешёнными только кликнутое требование и его более слабую версию // Например, {W} и {W/P} for (int j = 0; j < states.Length; j++) { if (i == j || isCostNeutral(j) || isWeakerRequirement(i, j)) { continue; } states[j] = FilterValueState.Prohibited; } } else if (allProhibited) { for (int j = 0; j < states.Length; j++) { if (i == j || isCostNeutral(j) && !isCostNeutral(i)) { continue; } states[j] = FilterValueState.Ignored; } } else { states[i] = FilterValueState.Prohibited; } }
private void applyUncheckCostLogic(StateClick click, FilterValueState[] states) { bool allAllowed = true; bool allProhibited = true; var i = click.ButtonIndex; for (int j = 0; j < states.Length; j++) { if (i == j) { continue; } allProhibited &= states[j] == FilterValueState.Prohibited; if (isCostNeutral(j)) { continue; } allAllowed &= states[j] == FilterValueState.Ignored; } if (allAllowed && !isCostNeutral(i)) { // Leave allowed only the clicked required value and it's weaker version // For example {W} и {W/P} for (int j = 0; j < states.Length; j++) { if (i == j || isCostNeutral(j) || isWeakerRequirement(i, j)) { continue; } states[j] = FilterValueState.Prohibited; } } else if (allProhibited) { for (int j = 0; j < states.Length; j++) { if (i == j || isCostNeutral(j) && !isCostNeutral(i)) { continue; } states[j] = FilterValueState.Ignored; } } else { states[i] = FilterValueState.Prohibited; } }
private void setButtonState(StateClick click, FilterValueState[] states) { FilterValueState[] filterValueStates = states; if ((int)filterValueStates[click.ButtonIndex] % 2 != (int)click.ClickedState % 2) { applyCheckLogic(click, states); } else if (EnableRequiringSome && filterValueStates[click.ButtonIndex] == FilterValueState.Ignored && click.ClickedState == FilterValueState.Ignored) { applyCheckLogic(click, states); } else { applyUncheckLogic(click, states); } }
private void applyCheckLogic(StateClick click, FilterValueState[] states) { var i = click.ButtonIndex; if (EnableMutuallyExclusive && click.ClickedState == FilterValueState.Required) { for (int j = 0; j < states.Length; j++) { if (j != i && states[j] == FilterValueState.Required) { states[j] = FilterValueState.Ignored; } } } if (EnableCostBehavior && click.MouseButton == MouseButtons.Left && states[i] == FilterValueState.Prohibited && click.ClickedState == FilterValueState.Ignored) { for (int j = 0; j < states.Length; j++) { if ((i == j || isWeakerRequirement(i, j)) && states[j] == FilterValueState.Prohibited) { states[j] = FilterValueState.Ignored; } } } if (EnableRequiringSome && states[i] != FilterValueState.RequiredSome && click.ClickedState == FilterValueState.Ignored) { states[i] = FilterValueState.RequiredSome; } else { states[i] = click.ClickedState; } }