public RenameConfigurationPresenter(IProjectModel model, IRenameConfigurationDialog dlg, string originalName)
        {
            this.model = model;
            this.dlg = dlg;
            this.originalName = originalName;

            dlg.ConfigurationName.Text = originalName;
            dlg.ConfigurationName.Select(0, originalName.Length);

            dlg.ConfigurationName.Changed += delegate
            {
                string text = dlg.ConfigurationName.Text;
                dlg.OkButton.Enabled = text != string.Empty && text != originalName;
            };

            dlg.OkButton.Execute += delegate
            {
                string newName = dlg.ConfigurationName.Text;

                foreach (string existingName in model.ConfigNames)
                {
                    if (existingName == newName)
                    {
                        dlg.MessageDisplay.Error("A configuration with that name already exists");
                        return;
                    }
                }

                model.Configs[originalName].Name = newName;
            };
        }
        public RenameConfigurationPresenter(IProjectModel model, IRenameConfigurationDialog dlg, string originalName)
        {
            this.model        = model;
            this.dlg          = dlg;
            this.originalName = originalName;

            dlg.ConfigurationName.Text = originalName;
            dlg.ConfigurationName.Select(0, originalName.Length);

            dlg.ConfigurationName.Changed += delegate
            {
                string text = dlg.ConfigurationName.Text;
                dlg.OkButton.Enabled = text != string.Empty && text != originalName;
            };

            dlg.OkButton.Execute += delegate
            {
                string newName = dlg.ConfigurationName.Text;

                foreach (string existingName in model.ConfigNames)
                {
                    if (existingName == newName)
                    {
                        dlg.MessageDisplay.Error("A configuration with that name already exists");
                        return;
                    }
                }

                model.Configs[originalName].Name = newName;
            };
        }
 public void Initialize()
 {
     IProjectDocument doc = new ProjectDocument();
     doc.LoadXml(NUnitProjectXml.EmptyConfigs);
     model = new ProjectModel(doc);
     dlg = Substitute.For<IRenameConfigurationDialog>();
     presenter = new RenameConfigurationPresenter(model, dlg, "Debug");
 }
Ejemplo n.º 4
0
        public void Initialize()
        {
            var doc = new ProjectModel();

            doc.LoadXml(NUnitProjectXml.EmptyConfigs);
            model     = new PropertyModel(doc);
            dlg       = Substitute.For <IRenameConfigurationDialog>();
            presenter = new RenameConfigurationPresenter(model, dlg, "Debug");
        }
Ejemplo n.º 5
0
        public void RenameConfig()
        {
            string oldName = view.ConfigList.SelectedItem;

            if (oldName.EndsWith(" (active)"))
            {
                oldName = oldName.Substring(0, oldName.Length - 9);
            }

            IRenameConfigurationDialog dlg = view.RenameConfigurationDialog;

            new RenameConfigurationPresenter(model, dlg, oldName);

            dlg.ShowDialog();

            UpdateConfigList();
        }