Exemplo n.º 1
0
        protected void CreateNewsList()
        {
            NewsOverviewTree.Nodes.Clear();

            var newsEnglish = from n in newsValues
                              where n.CultureCode == BRITISH_CULTURE
                              orderby n.NewsKey.NewsDate descending
                              select n;

            var numOfCultures = cultures.Count();

            // Node header
            string header;

            foreach (var n in newsEnglish)
            {
                TreeNode node = new TreeNode(n.HeaderText, n.NewsKeyID.ToString());
                node.ToolTip      = String.Format("{0:D}", n.NewsKey.NewsDate);
                node.SelectAction = TreeNodeSelectAction.Expand;

                NewsOverviewTree.Nodes.Add(node);

                foreach (var localizedNewsItem in newsValues.Where(x => x.NewsKeyID == n.NewsKeyID))
                {
                    string language     = cultures.Single(x => x.Code == localizedNewsItem.CultureCode).Name;
                    var    languageNode = new TreeNode(language, localizedNewsItem.CultureCode);
                    node.ChildNodes.Add(languageNode);
                }

                if (node.ChildNodes.Count < numOfCultures)
                {
                    var addLanugageNode = new TreeNode("Add new language", NEW_LANGUAGE);
                    node.ChildNodes.Add(addLanugageNode);
                }
            }

            NewsOverviewTree.CollapseAll();
        }
Exemplo n.º 2
0
        protected void CreateTreeView()
        {
            NewsOverviewTree.Nodes.Clear();

            var newsEnglish = from n in newsValues
                              where n.CultureCode == BRITISH_CULTURE
                              orderby n.NewsKey.NewsDate descending
                              select n;

            var numOfCultures = cultures.Count();

            // top level nodes in tree view
            var nodeTop    = new TreeNode("Top news");
            var nodeNonTop = new TreeNode("Other news");
            var nodeHidden = new TreeNode("Hidden news");

            nodeTop.SelectAction    = TreeNodeSelectAction.Expand;
            nodeNonTop.SelectAction = TreeNodeSelectAction.Expand;
            nodeHidden.SelectAction = TreeNodeSelectAction.Expand;

            // Node header
            string header;

            foreach (var n in newsEnglish)
            {
                TreeNode node = new TreeNode(n.HeaderText, n.NewsKeyID.ToString());
                node.ToolTip      = String.Format("{0:D}", n.NewsKey.NewsDate);
                node.SelectAction = TreeNodeSelectAction.Expand;

                // distrubute news items between 'hidden', 'top' and 'other'
                if (!n.NewsKey.Visible)
                {
                    nodeHidden.ChildNodes.Add(node);
                }
                else if (n.NewsKey.TopNewsIndicator)
                {
                    nodeTop.ChildNodes.Add(node);
                }
                else
                {
                    nodeNonTop.ChildNodes.Add(node);
                }

                // add a child node for each available translation
                foreach (var localizedNewsItem in newsValues.Where(x => x.NewsKeyID == n.NewsKeyID))
                {
                    string language     = cultures.Single(x => x.Code == localizedNewsItem.CultureCode).EnglishName;
                    var    languageNode = new TreeNode(language, localizedNewsItem.CultureCode);
                    node.ChildNodes.Add(languageNode);
                }

                // add a link to add a new translation
                if (node.ChildNodes.Count < numOfCultures)
                {
                    var addLanugageNode = new TreeNode("Add new language", NEW_LANGUAGE);
                    node.ChildNodes.Add(addLanugageNode);
                }
            }

            // add all top level nodes, if not empty
            if (nodeTop.ChildNodes.Count > 0)
            {
                NewsOverviewTree.Nodes.Add(nodeTop);
            }
            if (nodeNonTop.ChildNodes.Count > 0)
            {
                NewsOverviewTree.Nodes.Add(nodeNonTop);
            }
            if (nodeHidden.ChildNodes.Count > 0)
            {
                NewsOverviewTree.Nodes.Add(nodeHidden);
            }

            NewsOverviewTree.CollapseAll();
        }