Example #1
0
        /// <summary>
        /// This method fetch top X no of tags and add each as a
        /// link in the control in descending order based on
        /// the count of reference by the resource.
        /// </summary>
        private void AddChildControls()
        {
            this._tagCloudTable.Controls.Clear();
            this._tagCloudTable.Width = Unit.Percentage(100);
            this.CreateTitleRow();
            if (this.MaximumTagsToFetch == 0)
            {
                AddEmptyTableRow();
                return;
            }

            List <TagCloudEntry> tagCloudEntries = null;

            using (ResourceDataAccess dataAccess = new ResourceDataAccess(base.CreateContext()))
            {
                if (IsSecurityAwareControl)
                {
                    if (AuthenticatedToken != null)
                    {
                        tagCloudEntries = dataAccess.GetTopTagsForTagCloud(this.MaximumTagsToFetch, AuthenticatedToken);
                    }
                }
                else
                {
                    tagCloudEntries = dataAccess.GetTopTagsForTagCloud(this.MaximumTagsToFetch, null);
                }
            }

            if (tagCloudEntries == null || tagCloudEntries.Count == 0)
            {
                AddEmptyTableRow();
                return;
            }

            // Sort tags by "Name" property of tag for displaying tags in ascending order
            tagCloudEntries = tagCloudEntries.OrderBy(tagCloudEntry => tagCloudEntry.Tag.Name).ToList();

            this._densityLevels = GetDensityLevel();

            // Save tag's font size with corresponding reference count
            SetTagsFontSize(this._densityLevels, tagCloudEntries);

            AttachDisplayData(tagCloudEntries);
        }