コード例 #1
0
        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);
        }
コード例 #2
0
        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;
        }