public void textDepth_TextChanged(Object sender, EventArgs e) { if (mSelected == null) { return; } int old = mSelected.getStartDepth(); int value = old; string s = textDepth.Text; try { value = int.Parse(s); } catch (Exception ex) { value = old; } if (value < 0) { value = 0; } if (127 < value) { value = 127; } mSelected.setStartDepth(value); string nstr = value + ""; if (s != nstr) { textDepth.Text = nstr; textDepth.SelectionStart = textDepth.Text.Length; } repaintPictures(); }