Beispiel #1
0
 void BuildTreeRecursive(IList <Category> categories, DataboundTreeNode parentNode, object select)
 {
     if (categories == null)
     {
         return;
     }
     foreach (Category category in categories)
     {
         DataboundTreeNode categoryNode = new DataboundTreeNode(category.Name);
         categoryNode.TagPropertyBoundToText = "Name";
         categoryNode.Tag = category;
         if (parentNode == null)
         {
             tvGroups.Nodes.Add(categoryNode);
         }
         else
         {
             parentNode.Nodes.Add(categoryNode);
         }
         if (category == select)
         {
             tvGroups.SelectedNode = categoryNode;
         }
         if (category is Group)
         {
             categoryNode.ImageIndex         = 2;
             categoryNode.SelectedImageIndex = 2;
             if ((category as Group).Channels != null)
             {
                 foreach (Channel aChannel in (category as Group).Channels)
                 {
                     DataboundTreeNode aChannelNode = new DataboundTreeNode(aChannel.StreamName);
                     aChannelNode.TagPropertyBoundToText = "StreamName";
                     aChannelNode.ImageIndex             = 1;
                     aChannelNode.SelectedImageIndex     = 1;
                     aChannelNode.Tag = aChannel;
                     categoryNode.Nodes.Add(aChannelNode);
                     if (!categoryNode.IsExpanded)
                     {
                         categoryNode.Expand();
                     }
                     if (aChannel == select)
                     {
                         tvGroups.SelectedNode = aChannelNode;
                     }
                 }
             }
         }
         else
         {
             BuildTreeRecursive(category.SubCategories, categoryNode, select);
         }
     }
 }
 void BuildTreeRecursive(IList<Category> categories, DataboundTreeNode parentNode, object select)
 {
     if (categories == null) return;
     foreach (Category category in categories)
     {
         DataboundTreeNode categoryNode = new DataboundTreeNode(category.Name);
         categoryNode.TagPropertyBoundToText = "Name";
         categoryNode.Tag = category;
         if (parentNode == null) tvGroups.Nodes.Add(categoryNode);
         else parentNode.Nodes.Add(categoryNode);
         if (category == select) tvGroups.SelectedNode = categoryNode;
         if (category is Group)
         {
             categoryNode.ImageIndex = 2;
             categoryNode.SelectedImageIndex = 2;
             if ((category as Group).Channels != null)
             {
                 foreach (Channel aChannel in (category as Group).Channels)
                 {
                     DataboundTreeNode aChannelNode = new DataboundTreeNode(aChannel.StreamName);
                     aChannelNode.TagPropertyBoundToText = "StreamName";
                     aChannelNode.ImageIndex = 1;
                     aChannelNode.SelectedImageIndex = 1;
                     aChannelNode.Tag = aChannel;
                     categoryNode.Nodes.Add(aChannelNode);
                     if (!categoryNode.IsExpanded) categoryNode.Expand();
                     if (aChannel == select) tvGroups.SelectedNode = aChannelNode;
                 }
             }
         }
         else
         {
             BuildTreeRecursive(category.SubCategories, categoryNode, select);
         }
     }
 }