CodeTV.PanelChannel.InsertChannels C# (CSharp) Method

InsertChannels() private method

private InsertChannels ( Stream fileStream, ChannelFolder parentChannel, TreeNodeCollection parentTreeNodeCollection ) : void
fileStream Stream
parentChannel ChannelFolder
parentTreeNodeCollection System.Windows.Forms.TreeNodeCollection
return void
        internal void InsertChannels(Stream fileStream, ChannelFolder parentChannel, TreeNodeCollection parentTreeNodeCollection)
        {
            ChannelFolder channels = (ChannelFolder)Channel.Deserialize(fileStream);
            if (parentChannel == null)
                parentChannel = MainForm.rootChannelFolder;
            if (parentTreeNodeCollection == null)
                parentTreeNodeCollection = this.treeViewChannel.Nodes;

            // First level: we add to the existing folder
            // Second level: we adjust the parent
            foreach (Channel channel in channels.ChannelList)
            {
                parentChannel.Add(channel);

                TreeNode treeNode = MakeTreeNodeFromChannel(channel);

                if (channel is ChannelFolder)
                    RecursedFillTree(channel as ChannelFolder, treeNode.Nodes);

                parentTreeNodeCollection.Add(treeNode);
            }

            MainForm.UpdateChannelNumber();
        }