/// <summary>
 /// Adds the dropdown list.
 /// </summary>
 /// <param name="id">The activity control identifier.</param>
 /// <param name="displayName">The display name of the control.</param>
 /// <param name="description">The description of the control.</param>
 /// <param name="required">if set to true, the control is required. Otherwise not required.</param>
 /// <param name="visible">if set to true, the control is visible. Otherwise not visible.</param>
 /// <returns>The <see cref="ActivityDropDownList"/> object.</returns>
 private ActivityDropDownList AddDropDownList(string id, string displayName, string description, bool required, bool visible)
 {
     ActivityDropDownList control = new ActivityDropDownList(id, displayName, description, required, visible);
     this.AddActivityControl(control);
     return control;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="RunPowerShellScriptForm"/> class.
        /// </summary>
        public RunPowerShellScriptForm()
        {
            Logger.Instance.WriteMethodEntry();

            try
            {
                // Add standard controls to the form via the activity form controller
                this.activityDisplayName = this.controller.AddDisplayNameTextBox(ActivitySettings.ActivityDisplayName);

                this.advanced = this.controller.AddCheckBox(ActivitySettings.AdvancedFeatures, ActivitySettings.AdvancedFeaturesHelpText);
                this.advanced.CheckBoxControl.CheckedChanged += this.Advanced_CheckedChanged;
                this.advanced.CheckBoxControl.AutoPostBack = true;

                this.activityExecutionCondition = this.controller.AddTextBox(ActivitySettings.ActivityExecutionCondition, ActivitySettings.ConditionHelpText, false, false);

                this.powerShellUser = this.controller.AddTextBox(ActivitySettings.PowerShellUser, ActivitySettings.PowerShellUserHelpText, false, false);
                this.powerShellUserPassword = this.controller.AddTextBox(ActivitySettings.PowerShellUserPassword, ActivitySettings.PowerShellUserPasswordHelpText, false, false);

                this.impersonatePowerShellUser = this.controller.AddCheckBox(ActivitySettings.ImpersonatePowerShellUser, ActivitySettings.ImpersonatePowerShellUserHelpText, false, false);
                this.impersonatePowerShellUser.CheckBoxControl.CheckedChanged += this.ImpersonatePowerShellUser_CheckedChanged;
                this.impersonatePowerShellUser.CheckBoxControl.AutoPostBack = true;

                this.loadUserProfile = this.controller.AddCheckBox(ActivitySettings.LoadUserProfile, ActivitySettings.LoadUserProfileHelpText, false, false);
                this.impersonationLogOnType = this.controller.AddDropDownList(ActivitySettings.ImpersonationLogOnType, ActivitySettings.ImpersonationLogonTypeHelpText, false, false);

                this.scriptLocation = this.controller.AddDropDownList(ActivitySettings.PowerShellScriptLocation, ActivitySettings.PowerShellScriptLocationHelpText);
                this.script = this.controller.AddTextBox(ActivitySettings.PowerShellScript, ActivitySettings.PowerShellScriptHelpText, true);
                this.failOnMissing = this.controller.AddCheckBox(ActivitySettings.FailOnMissingScript, ActivitySettings.FailOnMissingScriptHelpText, false, false);
                this.inputType = this.controller.AddDropDownList(ActivitySettings.PowerShellScriptInputType, ActivitySettings.PowerShellScriptInputTypeHelpText);

                // Create a new instance of the definitions controller to capture parameters
                // The visibility of the parameters control will be based on the input type selection
                this.parameters = new DefinitionsController("Parameters", 150, 430, 0)
                {
                    DisplayName = ActivitySettings.NamedParameters,
                    Description = ActivitySettings.NamedParametersHelpText,
                    LeftHeader = ActivitySettings.NamedParametersLeftHeader,
                    RightHeader = ActivitySettings.NamedParametersRightHeader
                };
                this.parameters.HeaderRow.Visible = false;
                this.parameters.TableRow.Visible = false;
                this.controller.ActivityControlTable.Rows.Add(this.parameters.HeaderRow);
                this.controller.ActivityControlTable.Rows.Add(this.parameters.TableRow);

                // Create a new instance of the definitions controller to capture arguments
                // The visibility of the arguments control will be based on the input type selection
                this.arguments = new DefinitionsController("Arguments", 500, 0, 0)
                {
                    DisplayName = ActivitySettings.ScriptArguments,
                    Description = ActivitySettings.ScriptArgumentsHelpText,
                    LeftHeader = ActivitySettings.ScriptArgumentsLeftHeader
                };
                this.arguments.HeaderRow.Visible = false;
                this.arguments.TableRow.Visible = false;
                this.controller.ActivityControlTable.Rows.Add(this.arguments.HeaderRow);
                this.controller.ActivityControlTable.Rows.Add(this.arguments.TableRow);

                // Now that input controls have been added, add controls for return type
                // The return value lookup control will only be presented when explicit return is selected
                this.returnType = this.controller.AddDropDownList(ActivitySettings.ScriptReturnType, ActivitySettings.ScriptReturnTypeHelpText);
                this.returnValueLookup = this.controller.AddTextBox(ActivitySettings.ScriptReturnValueLookup, ActivitySettings.ScriptReturnValueLookupHelpText, false, false);

                // Configure controls
                this.script.TextBoxControl.TextMode = TextBoxMode.MultiLine;
                this.script.TextBoxControl.Wrap = false;
                this.script.TextBoxControl.Width = 300;
                this.script.TextBoxControl.Rows = 10;

                this.failOnMissing.Value = true;

                this.scriptLocation.AddListItem(ActivitySettings.ScriptLocationWorkflowDefinition, PowerShellScriptLocation.WorkflowDefinition.ToString());
                this.scriptLocation.AddListItem(ActivitySettings.ScriptLocationDisk, PowerShellScriptLocation.Disk.ToString());
                this.scriptLocation.AddListItem(ActivitySettings.ScriptLocationResolveLookup, PowerShellScriptLocation.Resource.ToString());
                this.scriptLocation.DropDownListControl.SelectedIndexChanged += this.ScriptLocation_SelectedIndexChanged;
                this.scriptLocation.DropDownListControl.AutoPostBack = true;

                this.inputType.AddListItem(ActivitySettings.PowerShellInputTypeNone, PowerShellInputType.None.ToString());
                this.inputType.AddListItem(ActivitySettings.PowerShellInputTypeNamedParameters, PowerShellInputType.Parameters.ToString());
                this.inputType.AddListItem(ActivitySettings.PowerShellInputTypeArguments, PowerShellInputType.Arguments.ToString());
                this.inputType.DropDownListControl.SelectedIndexChanged += this.InputType_SelectedIndexChanged;
                this.inputType.DropDownListControl.AutoPostBack = true;

                this.returnType.AddListItem(ActivitySettings.PowerShellReturnTypeNone, PowerShellReturnType.None.ToString());
                this.returnType.AddListItem(ActivitySettings.PowerShellReturnTypeSingleValue, PowerShellReturnType.Explicit.ToString());
                this.returnType.AddListItem(ActivitySettings.PowerShellReturnTypeTable, PowerShellReturnType.Table.ToString());
                this.returnType.DropDownListControl.SelectedIndexChanged += this.ReturnType_SelectedIndexChanged;
                this.returnType.DropDownListControl.AutoPostBack = true;

                this.impersonationLogOnType.AddListItem(ActivitySettings.ImpersonationLogOnTypeLogOnBatch, LogOnType.LogOnBatch.ToString());
                this.impersonationLogOnType.AddListItem(ActivitySettings.ImpersonationLogOnTypeLogOnNetwork, LogOnType.LogOnNetwork.ToString());
                this.impersonationLogOnType.AddListItem(ActivitySettings.ImpersonationLogOnTypeLogOnService, LogOnType.LogOnService.ToString());
                this.impersonationLogOnType.AddListItem(ActivitySettings.ImpersonationLogOnTypeLogOnNetworkClearText, LogOnType.LogOnNetworkClearText.ToString());
                this.impersonationLogOnType.AddListItem(ActivitySettings.ImpersonationLogOnTypeLogOnInteractive, LogOnType.LogOnInteractive.ToString());
            }
            catch (Exception e)
            {
                Logger.Instance.ReportError(e);
                throw;
            }
            finally
            {
                Logger.Instance.WriteMethodExit();
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UpdateResourcesForm"/> class.
        /// </summary>
        public UpdateResourcesForm()
        {
            Logger.Instance.WriteMethodEntry();

            try
            {
                // Add standard controls to the form via the activity form controller
                this.activityDisplayName = this.controller.AddDisplayNameTextBox(ActivitySettings.ActivityDisplayName);

                this.advanced = this.controller.AddCheckBox(ActivitySettings.AdvancedFeatures, ActivitySettings.AdvancedFeaturesHelpText);
                this.advanced.CheckBoxControl.CheckedChanged += this.Advanced_CheckedChanged;
                this.advanced.CheckBoxControl.AutoPostBack = true;

                this.queryResources = this.controller.AddCheckBox(ActivitySettings.QueryResources, ActivitySettings.QueryResourcesHelpText, false, false);
                this.queryResources.CheckBoxControl.CheckedChanged += this.QueryResources_CheckedChanged;
                this.queryResources.CheckBoxControl.AutoPostBack = true;

                // Create a new instance of the definitions controller to capture query definitions
                // The visibility of the queries control will be governed by the Query Resources checkbox
                this.queries = new DefinitionsController("Queries", 150, 430, 0)
                {
                    DisplayName = ActivitySettings.Queries,
                    Description = ActivitySettings.QueriesHelpText,
                    LeftHeader = ActivitySettings.QueriesLeftHeader,
                    RightHeader = ActivitySettings.QueriesRightHeader
                };
                this.queries.HeaderRow.Visible = false;
                this.queries.TableRow.Visible = false;
                this.controller.ActivityControlTable.Rows.Add(this.queries.HeaderRow);
                this.controller.ActivityControlTable.Rows.Add(this.queries.TableRow);

                this.activityExecutionCondition = this.controller.AddTextBox(ActivitySettings.ActivityExecutionCondition, ActivitySettings.ConditionHelpText, false, false);
                this.iteration = this.controller.AddTextBox(ActivitySettings.Iteration, ActivitySettings.IterationHelpText, false, false);

                this.actorType = this.controller.AddDropDownList(ActivitySettings.RequestActor, false, false);
                this.actorType.AddListItem(ActivitySettings.ServiceAccount, ActorType.Service.ToString());
                this.actorType.AddListItem(ActivitySettings.Requestor, ActorType.Requestor.ToString());
                this.actorType.AddListItem(ActivitySettings.ResolveFromExpression, ActorType.Resolve.ToString());
                this.actorType.AddListItem(ActivitySettings.SearchByAccountName, ActorType.Account.ToString());
                this.actorType.DropDownListControl.SelectedIndexChanged += this.ActorType_SelectedIndexChanged;
                this.actorType.DropDownListControl.AutoPostBack = true;

                this.actorString = this.controller.AddTextBox(ActivitySettings.ActorString, false, false);
                this.applyAuthorizationPolicy = this.controller.AddCheckBox(ActivitySettings.ApplyAuthorizationPolicy, ActivitySettings.ApplyAuthorizationPolicyHelpText, false, false);
                this.resolveDynamicGrammar = this.controller.AddCheckBox(ActivitySettings.ResolveDynamicGrammar, ActivitySettings.ResolveDynamicGrammarHelpText, false, false);

                // Create a new definitions controller to capture update definitions
                this.updates = new DefinitionsController("Updates", 330, 250, 70)
                {
                    DisplayName = ActivitySettings.Updates,
                    Description = ActivitySettings.UpdatesHelpText,
                    LeftHeader = ActivitySettings.UpdatesLeftHeader,
                    RightHeader = ActivitySettings.UpdatesRightHeader,
                    CheckHeader = ActivitySettings.UpdatesCheckHeader
                };
                this.controller.ActivityControlTable.Rows.Add(this.updates.HeaderRow);
                this.controller.ActivityControlTable.Rows.Add(this.updates.TableRow);
            }
            catch (Exception e)
            {
                Logger.Instance.ReportError(e);
                throw;
            }
            finally
            {
                Logger.Instance.WriteMethodExit();
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DeleteResourcesForm"/> class.
        /// </summary>
        public DeleteResourcesForm()
        {
            Logger.Instance.WriteMethodEntry();

            try
            {
                // Add the standard controls to the form via the activity form controller
                this.activityDisplayName = this.controller.AddDisplayNameTextBox(ActivitySettings.ActivityDisplayName);
                this.targetType = this.controller.AddDropDownList(ActivitySettings.TargetForDeletion, ActivitySettings.TargetForDeletionHelpText);

                this.advanced = this.controller.AddCheckBox(ActivitySettings.AdvancedFeatures, ActivitySettings.AdvancedFeaturesHelpText);
                this.advanced.CheckBoxControl.CheckedChanged += this.Advanced_CheckedChanged;
                this.advanced.CheckBoxControl.AutoPostBack = true;

                this.activityExecutionCondition = this.controller.AddTextBox(ActivitySettings.ActivityExecutionCondition, ActivitySettings.ConditionHelpText, false, false);
                this.iteration = this.controller.AddTextBox(ActivitySettings.Iteration, ActivitySettings.IterationHelpText, false, false);
                this.iteration.TextBoxControl.AutoPostBack = true;

                this.actorType = this.controller.AddDropDownList(ActivitySettings.RequestActor, false, false);
                this.actorType.AddListItem(ActivitySettings.ServiceAccount, ActorType.Service.ToString());
                this.actorType.AddListItem(ActivitySettings.Requestor, ActorType.Requestor.ToString());
                this.actorType.AddListItem(ActivitySettings.ResolveFromExpression, ActorType.Resolve.ToString());
                this.actorType.AddListItem(ActivitySettings.SearchByAccountName, ActorType.Account.ToString());
                this.actorType.DropDownListControl.SelectedIndexChanged += this.ActorType_SelectedIndexChanged;
                this.actorType.DropDownListControl.AutoPostBack = true;

                this.actorString = this.controller.AddTextBox(ActivitySettings.ActorString, false, false);
                this.applyAuthorizationPolicy = this.controller.AddCheckBox(ActivitySettings.ApplyAuthorizationPolicy, ActivitySettings.ApplyAuthorizationPolicyHelpText, false, false);
                this.applyAuthorizationPolicy.CheckBoxControl.AutoPostBack = true;

                this.targetExpression = this.controller.AddTextBox(ActivitySettings.TargetExpression, false, false);
                this.targetExpression.TextBoxControl.Width = 300;

                // Add list items to the target type drop down list and set an event handler
                this.targetType.AddListItem(ActivitySettings.UseWorkflowTarget, DeleteResourcesTargetType.WorkflowTarget.ToString());
                this.targetType.AddListItem(ActivitySettings.ResolveTargets, DeleteResourcesTargetType.ResolveTarget.ToString());
                this.targetType.AddListItem(ActivitySettings.SearchForTargets, DeleteResourcesTargetType.SearchForTarget.ToString());
                this.targetType.DropDownListControl.SelectedIndexChanged += this.TargetType_SelectedIndexChanged;
                this.targetType.DropDownListControl.AutoPostBack = true;
            }
            catch (Exception e)
            {
                Logger.Instance.ReportError(e);
                throw;
            }
            finally
            {
                Logger.Instance.WriteMethodExit();
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CreateResourceForm"/> class.
        /// </summary>
        public CreateResourceForm()
        {
            Logger.Instance.WriteMethodEntry();

            try
            {
                // Add standard controls to the form via the activity form controller
                this.activityDisplayName = this.controller.AddDisplayNameTextBox(ActivitySettings.ActivityDisplayName);
                this.resourceType = this.controller.AddTextBox(ActivitySettings.ResourceType, ActivitySettings.ResourceTypeHelpText, true);

                this.advanced = this.controller.AddCheckBox(ActivitySettings.AdvancedFeatures, ActivitySettings.AdvancedFeaturesHelpText);
                this.advanced.CheckBoxControl.CheckedChanged += this.Advanced_CheckedChanged;
                this.advanced.CheckBoxControl.AutoPostBack = true;

                this.queryResources = this.controller.AddCheckBox(ActivitySettings.QueryResources, ActivitySettings.QueryResourcesHelpText, false, false);
                this.queryResources.CheckBoxControl.CheckedChanged += this.QueryResources_CheckedChanged;
                this.queryResources.CheckBoxControl.AutoPostBack = true;

                // Create a new instance of the definitions controller to capture query definitions
                // The visibility of the queries control will be governed by the Query Resources checkbox
                this.queries = new DefinitionsController("Queries", 150, 430, 0)
                {
                    DisplayName = ActivitySettings.Queries,
                    Description = ActivitySettings.QueriesHelpText,
                    LeftHeader = ActivitySettings.QueriesLeftHeader,
                    RightHeader = ActivitySettings.QueriesRightHeader
                };
                this.queries.HeaderRow.Visible = false;
                this.queries.TableRow.Visible = false;
                this.controller.ActivityControlTable.Rows.Add(this.queries.HeaderRow);
                this.controller.ActivityControlTable.Rows.Add(this.queries.TableRow);

                this.activityExecutionCondition = this.controller.AddTextBox(ActivitySettings.ActivityExecutionCondition, ActivitySettings.ConditionHelpText, false, false);
                this.iteration = this.controller.AddTextBox(ActivitySettings.Iteration, ActivitySettings.IterationHelpText, false, false);
                this.iteration.TextBoxControl.TextChanged += this.Iteration_TextChanged;
                this.iteration.TextBoxControl.AutoPostBack = true;

                this.actorType = this.controller.AddDropDownList(ActivitySettings.RequestActor, false, false);
                this.actorType.AddListItem(ActivitySettings.ServiceAccount, ActorType.Service.ToString());
                this.actorType.AddListItem(ActivitySettings.Requestor, ActorType.Requestor.ToString());
                this.actorType.AddListItem(ActivitySettings.ResolveFromExpression, ActorType.Resolve.ToString());
                this.actorType.AddListItem(ActivitySettings.SearchByAccountName, ActorType.Account.ToString());
                this.actorType.DropDownListControl.SelectedIndexChanged += this.ActorType_SelectedIndexChanged;
                this.actorType.DropDownListControl.AutoPostBack = true;

                this.actorString = this.controller.AddTextBox(ActivitySettings.ActorString, false, false);
                this.applyAuthorizationPolicy = this.controller.AddCheckBox(ActivitySettings.ApplyAuthorizationPolicy, ActivitySettings.ApplyAuthorizationPolicyHelpText, false, false);
                this.applyAuthorizationPolicy.CheckBoxControl.CheckedChanged += this.ApplyAuthorizationPolicy_CheckedChanged;
                this.applyAuthorizationPolicy.CheckBoxControl.AutoPostBack = true;

                // Add additional controls
                // The visibility of conflict controls will be governed by the Check for Conflict checkbox
                this.createdResourceIdTarget = this.controller.AddTextBox(ActivitySettings.TargetForCreatedResourceID, ActivitySettings.TargetForCreatedResourceIDHelpText, false, false);
                this.checkForConflict = this.controller.AddCheckBox(ActivitySettings.CheckForConflict, ActivitySettings.CheckForConflictHelpText, false, false);
                this.checkForConflict.CheckBoxControl.CheckedChanged += this.CheckForConflict_CheckedChanged;
                this.checkForConflict.CheckBoxControl.AutoPostBack = true;

                this.conflictFilter = this.controller.AddTextBox(ActivitySettings.ConflictingResourceSearchFilter, ActivitySettings.ConflictingResourceSearchFilterHelpText, false, false);
                this.conflictFilter.TextBoxControl.Width = 300;

                this.conflictingResourceIdTarget = this.controller.AddTextBox(ActivitySettings.TargetForConflictingResourceID, ActivitySettings.TargetForConflictingResourceIDHelpText, false, false);
                this.failOnConflict = this.controller.AddCheckBox(ActivitySettings.FailOnConflict, ActivitySettings.FailOnConflictHelpText, false, false);

                // Create a new instance of hte definitions controller to capture attribute definitions
                this.attributes = new DefinitionsController("Attributes", 380, 200, 0)
                {
                    DisplayName = ActivitySettings.AttributesPopulation,
                    Description = ActivitySettings.AttributesPopulationHelpText,
                    LeftHeader = ActivitySettings.AttributesPopulationLeftHeader,
                    RightHeader = ActivitySettings.AttributesPopulationRightHeader
                };
                this.controller.ActivityControlTable.Rows.Add(this.attributes.HeaderRow);
                this.controller.ActivityControlTable.Rows.Add(this.attributes.TableRow);
            }
            catch (Exception e)
            {
                Logger.Instance.ReportError(e);
                throw;
            }
            finally
            {
                Logger.Instance.WriteMethodExit();
            }
        }