Esempio n. 1
0
        private static MathTimeSpan CheckMathTimeSpan(ITimeSpan timeSpan1, ITimeSpan timeSpan2, MathOperation operation, TimeSpanMode mode)
        {
            var mathTimeSpan = (operation == MathOperation.Add
                ? timeSpan1.Add(timeSpan2, mode)
                : timeSpan1.Subtract(timeSpan2, mode)) as MathTimeSpan;

            Assert.IsTrue(mathTimeSpan != null &&
                          mathTimeSpan.TimeSpan1.Equals(timeSpan1) &&
                          mathTimeSpan.TimeSpan2.Equals(timeSpan2) &&
                          mathTimeSpan.Operation == operation &&
                          mathTimeSpan.Mode == mode,
                          "Result is not a math time span.");

            return(mathTimeSpan);
        }
Esempio n. 2
0
        private static long CalculateBoundaryTime(long time, ITimeSpan size, MathOperation operation, TempoMap tempoMap)
        {
            ITimeSpan boundaryTime = (MidiTimeSpan)time;

            switch (operation)
            {
            case MathOperation.Add:
                boundaryTime = boundaryTime.Add(size, TimeSpanMode.TimeLength);
                break;

            case MathOperation.Subtract:
                var convertedSize = TimeConverter.ConvertFrom(size, tempoMap);
                boundaryTime = convertedSize > time
                        ? (MidiTimeSpan)0
                        : boundaryTime.Subtract(size, TimeSpanMode.TimeLength);
                break;
            }

            return(TimeConverter.ConvertFrom(boundaryTime, tempoMap));
        }