public int GetInputValue(bool IsRead) { int InputValue; string NumberStr; if (IsRead) { NumberStr = ReadMemoryBox.Text; } else { NumberStr = WriteMemoryBox.Text; } if (NumberStr.StartsWith("0x")) { NumberStr = NumberStr.Substring(2); InputValue = Int32.Parse(NumberStr, System.Globalization.NumberStyles.HexNumber); } else { InputValue = Int32.Parse(NumberStr); } return(InputValue); }
/// <summary> /// 返回鍵 /// </summary> public void BackSpace() { if (NumberStr.Length == 0) { return; } NumberStr = NumberStr.Substring(0, NumberStr.Length - 1); }
public string this[string columnName] { get { error = String.Empty; switch (columnName) { case "Year": if ((Year < 1900) && (Year != 0)) { error = "Ваш друг - динозавр? Думаю, нет"; } if ((Year > DateTime.Now.Year)) { error = "Наконец-то изобрели машину времени!"; } break; case "Day": if (Day < 0) { error = "Хотелось бы там побывать..."; } if (Day > 31) { error = "Бесконечный месяц? Надеюсь, на улице лето"; } break; case "Month": if (Month > 12) { error = "Да, и мне не 17 лет. Мне 15 лет и 30 месяцев... Кого мы обманываем..."; } if (Month < 0) { error = "Это тот самый секретный -1 месяц года?"; } break; case "NumberCodeStr": if (String.IsNullOrEmpty(NumberCodeStr)) { break; } if (NumberCodeStr.Trim().Length != 3) { error = "Код должен состоять из 3 цифр"; } try { NumberCode = Convert.ToInt32(NumberCodeStr); } catch { error = "Только цифры"; } break; case "NumberStr": if (String.IsNullOrEmpty(NumberStr)) { break; } if (NumberStr.Trim().Length != 7) { error = "Номер должен состоять из 7 цифр"; } try { Number = Convert.ToInt32(NumberStr); } catch { error = "Только цифры"; } break; } return(error); } }