/// <summary>
        /// Creates the group type editor controls.
        /// </summary>
        /// <param name="groupType">Type of the group.</param>
        private void CreateGroupTypeEditorControls(GroupType groupType, Control parentControl, bool forceGroupTypeEditorVisible = false)
        {
            CheckinGroupTypeEditor groupTypeEditor = new CheckinGroupTypeEditor();

            groupTypeEditor.ID = "GroupTypeEditor_" + groupType.Guid.ToString("N");
            groupTypeEditor.SetGroupType(groupType);
            groupTypeEditor.AddGroupClick           += groupTypeEditor_AddGroupClick;
            groupTypeEditor.AddGroupTypeClick       += groupTypeEditor_AddGroupTypeClick;
            groupTypeEditor.DeleteCheckinLabelClick += groupTypeEditor_DeleteCheckinLabelClick;
            groupTypeEditor.AddCheckinLabelClick    += groupTypeEditor_AddCheckinLabelClick;
            groupTypeEditor.DeleteGroupTypeClick    += groupTypeEditor_DeleteGroupTypeClick;
            groupTypeEditor.CheckinLabels            = null;
            groupTypeEditor.ForceContentVisible      = forceGroupTypeEditorVisible;

            if (GroupTypeCheckinLabelAttributesState.ContainsKey(groupType.Guid))
            {
                groupTypeEditor.CheckinLabels = GroupTypeCheckinLabelAttributesState[groupType.Guid];
            }

            if (groupTypeEditor.CheckinLabels == null)
            {
                // load CheckInLabels from Database if they haven't been set yet
                groupTypeEditor.CheckinLabels = new List <CheckinGroupTypeEditor.CheckinLabelAttributeInfo>();

                groupType.LoadAttributes();
                List <string>     labelAttributeKeys = CheckinGroupTypeEditor.GetCheckinLabelAttributes(groupType).Select(a => a.Key).ToList();
                BinaryFileService binaryFileService  = new BinaryFileService(new RockContext());

                foreach (string key in labelAttributeKeys)
                {
                    var attributeValue = groupType.GetAttributeValue(key);
                    int binaryFileId   = attributeValue.AsInteger() ?? 0;
                    var binaryFile     = binaryFileService.Get(binaryFileId);
                    if (binaryFile != null)
                    {
                        groupTypeEditor.CheckinLabels.Add(new CheckinGroupTypeEditor.CheckinLabelAttributeInfo {
                            AttributeKey = key, BinaryFileId = binaryFileId, FileName = binaryFile.FileName
                        });
                    }
                }
            }

            parentControl.Controls.Add(groupTypeEditor);

            foreach (var childGroup in groupType.Groups.OrderBy(a => a.Order).ThenBy(a => a.Name))
            {
                // get the GroupType from the control just in case it the InheritedFrom changed
                childGroup.GroupType = groupTypeEditor.GetCheckinGroupType();

                CreateGroupEditorControls(childGroup, groupTypeEditor, false);
            }

            foreach (var childGroupType in groupType.ChildGroupTypes.OrderBy(a => a.Order).ThenBy(a => a.Name))
            {
                CreateGroupTypeEditorControls(childGroupType, groupTypeEditor);
            }
        }
        /// <summary>
        /// Handles the AddGroupTypeClick event of the groupTypeEditor 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 groupTypeEditor_AddGroupTypeClick(object sender, EventArgs e)
        {
            CheckinGroupTypeEditor parentEditor = sender as CheckinGroupTypeEditor;

            parentEditor.ForceContentVisible = true;

            // CheckinArea is GroupType entity
            GroupType checkinArea = new GroupType();

            checkinArea.Guid              = Guid.NewGuid();
            checkinArea.IsSystem          = false;
            checkinArea.TakesAttendance   = true;
            checkinArea.AttendanceRule    = AttendanceRule.AddOnCheckIn;
            checkinArea.AttendancePrintTo = PrintTo.Default;
            checkinArea.ParentGroupTypes  = new List <GroupType>();
            checkinArea.ParentGroupTypes.Add(parentEditor.GetCheckinGroupType());
            checkinArea.LoadAttributes();

            CreateGroupTypeEditorControls(checkinArea, parentEditor);
        }