/// <summary>
 /// Sets the type of the workflow activity.
 /// </summary>
 /// <param name="value">The value.</param>
 public void SetForm( AttributeForm value )
 {
     EnsureChildControls();
     _hfFormGuid.Value = value.Guid.ToString();
     _tbFormName.Text = value.Name;
     _tbFormHeader.Text = value.Header;
     _tbFormFooter.Text = value.Footer;
     Expanded = value.Expanded;
 }
        /// <summary>
        /// Handles the Click event of the lbAddForm control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void lbAddForm_Click( object sender, EventArgs e )
        {
            ParseEditControls();

            var form = new AttributeForm();
            form.Guid = Guid.NewGuid();
            form.Expanded = true;
            form.Order = FormState.Any() ? FormState.Max( a => a.Order ) + 1 : 0;
            FormState.Add( form );

            BuildEditControls( true, form.Guid );
        }
        /// <summary>
        /// Builds the form control.
        /// </summary>
        /// <param name="parentControl">The parent control.</param>
        /// <param name="setValues">if set to <c>true</c> [set values].</param>
        /// <param name="form">The form.</param>
        /// <param name="activeFormGuid">The active form unique identifier.</param>
        /// <param name="showInvalid">if set to <c>true</c> [show invalid].</param>
        private void BuildFormControl( Control parentControl, bool setValues, AttributeForm form,
            Guid? activeFormGuid = null, bool showInvalid = false )
        {
            var control = new PersonAttributeFormEditor();
            control.ID = form.Guid.ToString( "N" );
            parentControl.Controls.Add( control );

            control.ValidationGroup = btnSave.ValidationGroup;

            control.DeleteFieldClick += tfeForm_DeleteFieldClick;
            control.ReorderFieldClick += tfeForm_ReorderFieldClick;
            control.EditFieldClick += tfeForm_EditFieldClick;
            control.RebindFieldClick += tfeForm_RebindFieldClick;
            control.DeleteFormClick += tfeForm_DeleteFormClick;
            control.AddFieldClick += tfeForm_AddFieldClick;

            control.SetForm( form );

            control.BindFieldsGrid( form.Fields );

            if ( setValues )
            {
                if ( !control.Expanded )
                {
                    control.Expanded = activeFormGuid.HasValue && activeFormGuid.Equals( form.Guid );
                }
            }
        }