コード例 #1
0
ファイル: Util.cs プロジェクト: sahwar/gnome-subtitles
        /// <summary>
        /// Note: Should be either used to set the first timing mode or to switch between modes.
        /// Should not be used if the timing mode is unchanged, as events will be assigned again.
        /// </summary>
        /// <param name="spinButton">Spin button.</param>
        /// <param name="timingMode">Timing mode.</param>
        /// <param name="frameRateForConversion">Frame rate for conversion if the spin button has a value. Use 0 for no conversion.</param>
        public static void SetSpinButtonTimingMode(SpinButton spinButton, TimingMode timingMode, float frameRateForConversion)
        {
            bool convertValue = (spinButton.ValueAsInt > 0) && (frameRateForConversion > float.Epsilon);
            int  oldValue     = spinButton.ValueAsInt;

            //Switching to Frames mode

            if (timingMode == TimingMode.Frames)
            {
                spinButton.Numeric = true;
                spinButton.Input  -= OnTimeInput;
                spinButton.Output -= OnTimeOutput;

                //Even if the value isn't converted, we need to set the old one in order for the input to be shown with the new format
                spinButton.Value = (convertValue ? TimingUtil.TimeMillisecondsToFrames(oldValue, frameRateForConversion) : oldValue);

                return;
            }

            //Switching to Times mode

            spinButton.Numeric = false;
            spinButton.Input  += OnTimeInput;
            spinButton.Output += OnTimeOutput;

            //Even if the value isn't converted, we need to set the old one in order for the input to be shown with the new format
            spinButton.Value = (convertValue ? TimingUtil.FramesToTime(oldValue, frameRateForConversion).TotalMilliseconds : oldValue);
        }
コード例 #2
0
        private void ParseStartTime(Match match, Times times, Times previousTimes, ParsingProperties properties)
        {
            bool     isTimeDefined = false;
            TimeSpan startTime     = new TimeSpan(0);

            int   result      = 0;
            float floatResult = 0;

            if (ParseGroup(match, "StartHours", ref result))
            {
                startTime    += TimeSpan.FromHours(result);
                isTimeDefined = true;
            }
            if (ParseGroup(match, "StartMinutes", ref result))
            {
                startTime    += TimeSpan.FromMinutes(result);
                isTimeDefined = true;
            }
            if (ParseGroup(match, "StartSeconds", ref result))
            {
                startTime    += TimeSpan.FromSeconds(result);
                isTimeDefined = true;
            }
            if (ParseGroup(match, "StartDeciseconds", ref result))
            {
                startTime    += TimeSpan.FromMilliseconds(result * 100);
                isTimeDefined = true;
            }
            if (ParseGroup(match, "StartCentiseconds", ref result))
            {
                startTime    += TimeSpan.FromMilliseconds(result * 10);
                isTimeDefined = true;
            }
            if (ParseGroup(match, "StartMilliseconds", ref result))
            {
                startTime    += TimeSpan.FromMilliseconds(result);
                isTimeDefined = true;
            }
            if (ParseGroup(match, "StartMillisecondsAsFrames", ref result))
            {
                startTime    += TimingUtil.FramesToTime(result, properties.InputFrameRate);
                isTimeDefined = true;
            }

            if (ParseGroup(match, "StartElapsedTime", ref floatResult))
            {
                if (previousTimes != null)
                {
                    startTime += previousTimes.PreciseEnd;
                }

                startTime    += TimeSpan.FromSeconds(floatResult);
                isTimeDefined = true;
            }
            if (isTimeDefined)
            {
                times.PreciseStart = startTime;
            }
        }
コード例 #3
0
ファイル: Video.cs プロジェクト: sahwar/gnome-subtitles
        public void Seek(int frames)
        {
            if (!isLoaded)
            {
                return;
            }

            TimeSpan time = TimingUtil.FramesToTime(frames, this.FrameRate);

            Seek(time);
        }
コード例 #4
0
        private void ParseEndTime(Match match, Times times, Times previousTimes, ParsingProperties properties)
        {
            bool     isTimeDefined = false;
            TimeSpan endTime       = new TimeSpan(0);

            int   result      = 0;
            float floatResult = 0;

            if (ParseGroup(match, "EndHours", ref result))
            {
                endTime      += TimeSpan.FromHours(result);
                isTimeDefined = true;
            }
            if (ParseGroup(match, "EndMinutes", ref result))
            {
                endTime      += TimeSpan.FromMinutes(result);
                isTimeDefined = true;
            }
            if (ParseGroup(match, "EndSeconds", ref result))
            {
                endTime      += TimeSpan.FromSeconds(result);
                isTimeDefined = true;
            }
            if (ParseGroup(match, "EndDeciseconds", ref result))
            {
                endTime      += TimeSpan.FromMilliseconds(result * 100);
                isTimeDefined = true;
            }
            if (ParseGroup(match, "EndCentiseconds", ref result))
            {
                endTime      += TimeSpan.FromMilliseconds(result * 10);
                isTimeDefined = true;
            }
            if (ParseGroup(match, "EndMilliseconds", ref result))
            {
                endTime      += TimeSpan.FromMilliseconds(result);
                isTimeDefined = true;
            }
            if (ParseGroup(match, "EndMillisecondsAsFrames", ref result))
            {
                endTime      += TimingUtil.FramesToTime(result, properties.InputFrameRate);
                isTimeDefined = true;
            }
            if (ParseGroup(match, "EndElapsedTime", ref floatResult))
            {
                endTime      += times.PreciseStart + TimeSpan.FromSeconds(floatResult);
                isTimeDefined = true;
            }
            if (isTimeDefined)
            {
                times.PreciseEnd = endTime;
            }
        }
コード例 #5
0
        private void ProcessTweens()
        {
            var timeStep = TimingUtil.FramesToTime(1);

            _currentTween = _head;

            while (_currentTween != null)
            {
                _nextTweener = _currentTween.next;

                if (_currentTween.isRemoved)
                {
                    RemoveTween(_currentTween);
                }
                else
                {
                    if (!_currentTween.isActive)
                    {
                        _currentTween.Activate();
                        OverrideProperties(_currentTween);
                    }

                    _currentTween.DoStep(timeStep);

                    if (_currentTween.isRemoved)
                    {
                        RemoveTween(_currentTween);
                    }
                    else if (_currentTween.isCompleted)
                    {
                        FinishTween(_currentTween);
                    }
                }

                _currentTween = _nextTweener;
            }

            UpdateDispatcher();
        }
コード例 #6
0
 internal void UpdateEndTimeFromFrames(float frameRate)
 {
     times.PreciseEnd = TimingUtil.FramesToTime(frames.PreciseEnd, frameRate);
 }
コード例 #7
0
 internal void UpdateStartTimeFromFrames(float frameRate)
 {
     times.PreciseStart = TimingUtil.FramesToTime(frames.PreciseStart, frameRate);
 }