private void spMaxQuadSide_ValueChanged(object sender, System.EventArgs e) { int val = (int)spMaxQuadSide.Value; if (BitOps.IsPow2((long)val)) { return; } if (val > MaxQuadSide) { MaxQuadSide = (int)BitOps.NextPow2((long)val); } else { MaxQuadSide = (int)BitOps.PrevPow2((long)val); } if (MaxQuadSide > RectPartition.c_MaxQuadSide) { MaxQuadSide = RectPartition.c_MaxQuadSide; } spMaxQuadSide.Value = MaxQuadSide; }