private void SetProperValue(int val) { if (val < barMinimum) Value = barMinimum; else if (val > barMaximum) Value = barMaximum; else Value = val; }