public static RecurringRecordingList MergeLists(RecurringRecordingList[] lists, int length)
        {
            if (lists == null || lists.Length == 0 || length < 1)
            {
                return(null);
            }
            if (length > lists.Length)
            {
                length = lists.Length;
            }
            if (length == 1)
            {
                return(lists[0]);
            }
            int count = 0;

            for (int i = 0; i < length; i++)
            {
                count += lists[i].mList.Count;
            }
            RecurringRecordingList list = new RecurringRecordingList(count);

            for (int j = 0; j < length; j++)
            {
                count = lists[j].mList.Count;
                for (int k = 0; k < count; k++)
                {
                    list.mList.Add(lists[j].mList[k]);
                }
            }
            list.checkChannelOID();
            return(list);
        }
 public void GroupByChannel(RecNameSort sortByName, RecSizeSort sortBySize)
 {
     if (this.mChannelOID == 0)
     {
         int i, channelOID;
         RecurringRecordingList list;
         Dictionary <int, RecurringRecordingList> channelTable = new Dictionary <int, RecurringRecordingList>();
         for (i = 0; i < this.mList.Count; i++)
         {
             channelOID = this.mList[i].ChannelOID;
             if (!channelTable.TryGetValue(channelOID, out list))
             {
                 list              = new RecurringRecordingList();
                 list.mChannelOID  = channelOID;
                 list.mChannelName = this.mList[i].ChannelName;
                 list.mList        = new List <RecurringRecording>();
                 channelTable.Add(channelOID, list);
             }
             list.mList.Add(this.mList[i]);
         }
         if (sortByName != RecNameSort.None || sortBySize != RecSizeSort.None)
         {
             KeyValuePair <int, RecurringRecordingList>[] sortedTable = new KeyValuePair <int, RecurringRecordingList> [channelTable.Count];
             i = 0;
             foreach (KeyValuePair <int, RecurringRecordingList> channel in channelTable)
             {
                 sortedTable[i++] = channel;
             }
             sRecListComparer.SortByName = sortByName;
             sRecListComparer.SortBySize = sortBySize;
             Array.Sort(sortedTable, sRecListComparer);
             this.mList.Clear();
             for (int j = 0; j < sortedTable.Length; j++)
             {
                 list = sortedTable[j].Value;
                 for (i = 0; i < list.mList.Count; i++)
                 {
                     this.mList.Add(list.mList[i]);
                 }
             }
         }
         else
         {
             this.mList.Clear();
             foreach (KeyValuePair <int, RecurringRecordingList> channel in channelTable)
             {
                 list = channel.Value;
                 for (i = 0; i < list.mList.Count; i++)
                 {
                     this.mList.Add(list.mList[i]);
                 }
             }
         }
     }
 }
        public RecurringRecordingList[] DivideByChannel(RecNameSort sortByName, RecSizeSort sortBySize)
        {
            RecurringRecordingList[] channels;
            if (this.mChannelOID != 0)
            {
                channels    = new RecurringRecordingList[1];
                channels[0] = this;
                return(channels);
            }
            int i, channelOID;
            RecurringRecordingList list;
            Dictionary <int, RecurringRecordingList> channelTable = new Dictionary <int, RecurringRecordingList>();

            for (i = 0; i < this.mList.Count; i++)
            {
                channelOID = this.mList[i].ChannelOID;
                if (!channelTable.TryGetValue(channelOID, out list))
                {
                    list              = new RecurringRecordingList();
                    list.mChannelOID  = channelOID;
                    list.mChannelName = this.mList[i].ChannelName;
                    list.mList        = new List <RecurringRecording>();
                    channelTable.Add(channelOID, list);
                }
                list.mList.Add(this.mList[i]);
            }
            channelOID = 0;
            channels   = new RecurringRecordingList[channelTable.Count];
            if (sortByName != RecNameSort.None || sortBySize != RecSizeSort.None)
            {
                i = 0;
                KeyValuePair <int, RecurringRecordingList>[] sortedTable = new KeyValuePair <int, RecurringRecordingList> [channelTable.Count];
                foreach (KeyValuePair <int, RecurringRecordingList> channel in channelTable)
                {
                    sortedTable[i++] = channel;
                }
                sRecListComparer.SortByName = sortByName;
                sRecListComparer.SortBySize = sortBySize;
                Array.Sort(sortedTable, sRecListComparer);
                for (i = 0; i < sortedTable.Length; i++)
                {
                    channels[i] = sortedTable[i].Value;
                }
            }
            else
            {
                i = 0;
                foreach (KeyValuePair <int, RecurringRecordingList> channel in channelTable)
                {
                    channels[i++] = channel.Value;
                }
            }
            return(channels);
        }