Esempio n. 1
0
        private void UpdateCloud()
        {
            IUnityContainer container = (IUnityContainer)HttpContext.Current.Application["unityContainer"];

            ILabelService labelService = container.Resolve <ILabelService>();

            DictionaryBlock <string, long> labelMap = labelService.GetMostValuedLabels(0, Settings.Default.WebMovies_labelsPerCloud);

            if (labelMap.Count == 0)
            {
                UpdateCloudFake();
                return;
            }
            double max = labelMap.Values.Max();
            double min = labelMap.Values.Min();

            SortedSet <ListItem> labels = new SortedSet <ListItem>(new AlphabeticalListItemTextComparer());

            foreach (string label in labelMap.Keys)
            {
                double rating  = labelMap[label];
                int    minSize = 30;
                if (max > min)
                {
                    minSize = (int)((rating - min) / (max - min) * 20.0 + 20.0);
                }
                ListItem listItem = new ListItem(label, minSize.ToString());
                labels.Add(listItem);
            }

            CloudView.DataSource = labels;
            CloudView.DataBind();
        }