/// <summary> /// Initializes a new instance of the <see cref="ScenarioConfigurationControlForm"/> class. /// </summary> /// <param name="tag">The tag.</param> public ScenarioConfigurationControlForm(ConfigurationObjectTag tag, EnterpriseTestContext context) : this() { _control = ScenarioConfigurationControlFactory.Create(tag, context); _control.Initialize(tag); scenarioConfigurationControl_Panel.Controls.Add(_control as Control); (_control as Control).Dock = DockStyle.Fill; }
private void scenarioConfigurationTreeView_ConfigurationObjectSelected(object sender, ConfigurationTagEventArgs e) { _refreshEvent = e; this.Cursor = Cursors.WaitCursor; resource_ToolStrip.Visible = false; main_StatusLabel.Text = string.Empty; dataEditPanel.SuspendLayout(); try { // Remove all controls from the data edit panel ClearEditPanel(); // Load the entity object from the database EntityObject entity = _enterpriseTestUIController.GetEntityObject(e.Tag.Id); if (entity == null) { // This will be caught by the EnterpriseScenarioTreeView as a result of the ConfigurationObjectSelected event. throw new InvalidOperationException("Object does not exist."); } _currentlyDisplayedItemId = e.Tag.Id; try { // Create the configuration control and add to the panel IScenarioConfigurationControl control = ScenarioConfigurationControlFactory.Create(e.Tag, _enterpriseTestUIController.Context); if (control != null) { control.Initialize(entity); dataEditPanel.Controls.Add(control as Control); (control as Control).Dock = DockStyle.Fill; // Set the title of this edit form resource_ToolStripLabel.Text = control.EditFormTitle; // Configure and show the tool bar resource_ToolStrip.Visible = !e.Tag.ObjectType.IsFolder(); executeScenario_ToolStripButton.Visible = e.Tag.ObjectType == ConfigurationObjectType.EnterpriseScenario; analyze_ToolStripButton.Visible = e.Tag.ObjectType == ConfigurationObjectType.EnterpriseScenario; executeScenario_ToolStripButton.Enabled = _sessionManager.AbleToStartNewSession; } } catch (ControlTypeMismatchException ex) { MessageBox.Show(ex.Message, "Configuration Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } finally { dataEditPanel.ResumeLayout(); this.Cursor = Cursors.Default; } }