예제 #1
0
        public override void Execute()
        {
            base.Execute();

            if (!_explicitNewValuePassed)
            {
                var dialog = new TypeTextOrCancelDialog("Rename " + _nameable.GetType().Name, "Name", 2000, _nameable.Name);
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    while (UsefulStuff.IsBadName(dialog.ResultText))
                    {
                        if (YesNo("Name contains illegal characters, do you want to use it anyway?", "Bad Name"))
                        {
                            //user wants to use the name anyway
                            break;
                        }

                        //user does not want to use the bad name

                        //type a new one then
                        dialog = new TypeTextOrCancelDialog("Rename " + _nameable.GetType().Name, "Name", 2000, dialog.ResultText);

                        //no? in that case lets just give up altogether
                        if (dialog.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }
                    }
                    _newValue = dialog.ResultText;
                }
                else
                {
                    return;
                }
            }

            _nameable.Name = _newValue;
            EnsureNameIfCohortIdentificationAggregate();

            _nameable.SaveToDatabase();
            Publish((DatabaseEntity)_nameable);
        }
예제 #2
0
        public override void Execute()
        {
            base.Execute();

            if (!_explicitNewValuePassed)
            {
                if (TypeText("Rename " + _nameable.GetType().Name, "Name", 2000, _nameable.Name, out string text))
                {
                    while (UsefulStuff.IsBadName(text))
                    {
                        if (YesNo("Name contains illegal characters, do you want to use it anyway?", "Bad Name"))
                        {
                            //user wants to use the name anyway
                            break;
                        }

                        //user does not want to use the bad name

                        //type a new one then

                        if (!TypeText("Rename " + _nameable.GetType().Name, "Name", 2000, _nameable.Name, out text))
                        {
                            return;
                        }
                    }

                    _newValue = text;
                }
                else
                {
                    return;
                }
            }

            _nameable.Name = _newValue;
            EnsureNameIfCohortIdentificationAggregate();

            _nameable.SaveToDatabase();
            Publish((DatabaseEntity)_nameable);
        }