示例#1
0
        /// <summary>
        /// Merge close Time lines if volume the same
        /// </summary>
        private void MergeTimeLines()
        {
            // save all indexes to delete and then delete those indexes

            TimeLineVolume PreviousTimeLine = DetectedTime[0];

            for (int i = 1; i < DetectedTime.Count; i++)
            {
                if (PreviousTimeLine.Volume == DetectedTime[i].Volume)
                {
                    // set Previous timeLine.end next timeLine.end
                    PreviousTimeLine.End = DetectedTime[i].End;

                    // then delete because we merged this time lines
                    DetectedTime.RemoveAt(i);

                    // we have deleted time line we need to decrease i value
                    i--;

                    // and we set value to item with longer duration
                    DetectedTime[i] = PreviousTimeLine;
                }
                else
                {
                    DetectedTime[i - 1] = PreviousTimeLine;
                    PreviousTimeLine    = DetectedTime[i];
                }
            }
        }
示例#2
0
        /// <summary>
        /// delete all time lines where duration is 0
        /// </summary>
        private void DeleteEmptyTimeLines()
        {
            for (int i = 0; i < DetectedTime.Count; i++)
            {
                if (DetectedTime[i].Duration == TimeSpan.Zero)
                {
                    DetectedTime.RemoveAt(i);

                    // we deleted item at i index, so we next one shift to i - 1 index

                    i--;
                }
            }
        }