public ICommand CreateCommand() { ICommand ret = null; // bool add = false; (unused) // add = true; string title = "Add Water"; bool showAgain = false; using (TextPromptDialog dlg = new TextPromptDialog(title, "Water height (mm):", anchor, "&Add")) { do { showAgain = false; dlg.TextBoxText = app.Config.WaterHeightDefault.ToString(); float h; DialogResult dlgRes = dlg.ShowDialog(); if (dlgRes == DialogResult.OK && float.TryParse(dlg.TextBoxText, out h)) { ret = new AddWaterCommand(app, bound, h); } else { if (dlgRes != DialogResult.Cancel) { MessageBox.Show("Height can not be parsed to a floating point number", "Incorrect height", MessageBoxButtons.OK); showAgain = true; } else { return(null); } } } while (showAgain); } return(ret); }
public ICommand CreateCommand() { ICommand ret = null; // bool add = false; (unused) // add = true; string title = "Add Water"; bool showAgain = false; using (TextPromptDialog dlg = new TextPromptDialog(title, "Water height (mm):", anchor, "&Add")) { do { showAgain = false; dlg.TextBoxText = app.Config.WaterHeightDefault.ToString(); float h; DialogResult dlgRes = dlg.ShowDialog(); if (dlgRes == DialogResult.OK && float.TryParse(dlg.TextBoxText, out h)) { ret = new AddWaterCommand(app, bound, h); } else { if (dlgRes != DialogResult.Cancel) { MessageBox.Show("Height can not be parsed to a floating point number", "Incorrect height", MessageBoxButtons.OK); showAgain = true; } else { return null; } } } while (showAgain); } return ret; }