public void OnVideoSetSubtitleStartEndButtonRelease(object o, ButtonReleaseEventArgs args) { if (args.Event.Button != 1) { return; } if (Base.TimingMode == TimingMode.Times) { TimeSpan time = Base.Ui.Video.Position.CurrentTime; if (Base.Ui.Video.IsStatePlaying && Base.Config.VideoApplyReactionDelay) { time -= TimeSpan.FromMilliseconds(Base.Config.VideoReactionDelay); } Base.CommandManager.Execute(new VideoSetSubtitleEndCommand(time)); Base.Ui.View.SelectNextSubtitle(); } else { int frames = Base.Ui.Video.Position.CurrentFrames; if (Base.Ui.Video.IsStatePlaying && Base.Config.VideoApplyReactionDelay) { frames -= (int)TimingUtil.TimeMillisecondsToFrames(Base.Config.VideoReactionDelay, Base.Ui.Video.FrameRate); } Base.CommandManager.Execute(new VideoSetSubtitleEndCommand(frames)); Base.Ui.View.SelectNextSubtitle(); } }
/// <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); }
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; } }
public void Seek(int frames) { if (!isLoaded) { return; } TimeSpan time = TimingUtil.FramesToTime(frames, this.FrameRate); Seek(time); }
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; } }
private void UpdateLengthLabel(TimingMode timingMode, TimeSpan length) { if (timingMode == TimingMode.Times) { lengthValueLabel.Text = Util.TimeSpanToText(length); } else { double frames = (length == TimeSpan.Zero ? 0 : TimingUtil.TimeToFrames(length, player.FrameRate)); lengthValueLabel.Text = Convert.ToInt32(frames).ToString(); } }
private void UpdatePositionValueLabel(TimeSpan newPosition) { if (Base.TimingMode == TimingMode.Times) { positionValueLabel.Text = Util.TimeSpanToText(newPosition); } else { double frames = (newPosition == TimeSpan.Zero ? 0 : TimingUtil.TimeToFrames(newPosition, player.FrameRate)); positionValueLabel.Text = Convert.ToInt32(frames).ToString(); } }
public void OnVideoSetSubtitleStart(object o, EventArgs args) { if (Base.TimingMode == TimingMode.Times) { TimeSpan time = Base.Ui.Video.Position.CurrentTime; if (Base.Ui.Video.IsStatePlaying && Base.Config.VideoApplyReactionDelay) { time -= TimeSpan.FromMilliseconds(Base.Config.VideoReactionDelay); } Base.CommandManager.Execute(new VideoSetSubtitleStartCommand(time)); } else { int frames = Base.Ui.Video.Position.CurrentFrames; if (Base.Ui.Video.IsStatePlaying && Base.Config.VideoApplyReactionDelay) { frames -= (int)TimingUtil.TimeMillisecondsToFrames(Base.Config.VideoReactionDelay, Base.Ui.Video.FrameRate); } Base.CommandManager.Execute(new VideoSetSubtitleStartCommand(frames)); } }
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(); }
internal void UpdateEndTimeFromFrames(float frameRate) { times.PreciseEnd = TimingUtil.FramesToTime(frames.PreciseEnd, frameRate); }
internal void UpdateStartTimeFromFrames(float frameRate) { times.PreciseStart = TimingUtil.FramesToTime(frames.PreciseStart, frameRate); }
internal void UpdateEndFrameFromTimes(float frameRate) { frames.PreciseEnd = TimingUtil.TimeToFrames(times.PreciseEnd, frameRate); }
internal void UpdateStartFrameFromTimes(float frameRate) { frames.PreciseStart = TimingUtil.TimeToFrames(times.PreciseStart, frameRate); }
/* Private members */ private string FieldEvaluator(Match match) { Group fieldGroup = match.Groups["Field"]; string field = fieldGroup.Value; switch (field) { case "StartFrame": int startFrame = subtitle.Frames.Start; return(FormatedField(startFrame, match)); case "StartElapsedFrames": int previousFrames = (previousSubtitle == null ? 0 : previousSubtitle.Frames.End); int startElapsedFrames = subtitle.Frames.Start - previousFrames; return(FormatedField(startElapsedFrames, match)); case "EndFrame": int endFrame = subtitle.Frames.End; return(FormatedField(endFrame, match)); case "EndElapsedFrames": int endElapsedFrames = subtitle.Frames.Duration; return(FormatedField(endElapsedFrames, match)); case "StartHours": int startHours = subtitle.Times.Start.Hours; return(FormatedField(startHours, 2, match)); case "StartMinutes": int startMinutes = subtitle.Times.Start.Minutes; return(FormatedField(startMinutes, 2, match)); case "StartSeconds": int startSeconds = subtitle.Times.Start.Seconds; return(FormatedField(startSeconds, 2, match)); case "StartDeciseconds": int startDeciseconds = DivideAndRound(subtitle.Times.Start.Milliseconds, 100); return(FormatedField(startDeciseconds, 1, match)); case "StartTotalDeciseconds": int startTotalDeciseconds = DivideAndRound((int)subtitle.Times.Start.TotalMilliseconds, 100); return(startTotalDeciseconds.ToString()); case "StartCentiseconds": int startCentiseconds = DivideAndRound(subtitle.Times.Start.Milliseconds, 10); return(FormatedField(startCentiseconds, 2, match)); case "StartMilliseconds": int startMilliseconds = subtitle.Times.Start.Milliseconds; return(FormatedField(startMilliseconds, 3, match)); case "StartMillisecondsAsFrames": int startMillisecondsAsFrames = (int)TimingUtil.TimeMillisecondsToFrames(subtitle.Times.Start.Milliseconds, this.subtitleProperties.CurrentFrameRate); return(FormatedField(startMillisecondsAsFrames, 2, match)); case "StartMillisecondsAsFramesPAL": int startMillisecondsAsFramesPAL = (int)TimingUtil.TimeMillisecondsToFrames(subtitle.Times.Start.Milliseconds, 25); return(FormatedField(startMillisecondsAsFramesPAL, 2, match)); case "StartMillisecondsAsFramesNTSC": int startMillisecondsAsFramesNTSC = (int)TimingUtil.TimeMillisecondsToFrames(subtitle.Times.Start.Milliseconds, 29.97F); return(FormatedField(startMillisecondsAsFramesNTSC, 2, match)); case "EndMillisecondsAsFrames": int endMillisecondsAsFrames = (int)TimingUtil.TimeMillisecondsToFrames(subtitle.Times.End.Milliseconds, this.subtitleProperties.CurrentFrameRate); return(FormatedField(endMillisecondsAsFrames, 2, match)); case "EndMillisecondsAsFramesPAL": int endMillisecondsAsFramesPAL = (int)TimingUtil.TimeMillisecondsToFrames(subtitle.Times.End.Milliseconds, 25); return(FormatedField(endMillisecondsAsFramesPAL, 2, match)); case "EndMillisecondsAsFramesNTSC": int endMillisecondsAsFramesNTSC = (int)TimingUtil.TimeMillisecondsToFrames(subtitle.Times.End.Milliseconds, 29.97F); return(FormatedField(endMillisecondsAsFramesNTSC, 2, match)); case "StartElapsedTime": TimeSpan previousTime = (previousSubtitle == null ? TimeSpan.Zero : previousSubtitle.Times.End); TimeSpan startElapsedTime = subtitle.Times.Start - previousTime; return(FormatedField(startElapsedTime.TotalSeconds)); case "EndHours": int endHours = subtitle.Times.End.Hours; return(FormatedField(endHours, 2, match)); case "EndMinutes": int endMinutes = subtitle.Times.End.Minutes; return(FormatedField(endMinutes, 2, match)); case "EndSeconds": int endSeconds = subtitle.Times.End.Seconds; return(FormatedField(endSeconds, 2, match)); case "EndDeciseconds": int endDeciseconds = DivideAndRound(subtitle.Times.End.Milliseconds, 100); return(FormatedField(endDeciseconds, 1, match)); case "EndTotalDeciseconds": int endTotalDeciseconds = DivideAndRound((int)subtitle.Times.End.TotalMilliseconds, 100); return(endTotalDeciseconds.ToString()); case "EndCentiseconds": int endCentiseconds = DivideAndRound(subtitle.Times.End.Milliseconds, 10); return(FormatedField(endCentiseconds, 2, match)); case "EndMilliseconds": int endMilliseconds = subtitle.Times.End.Milliseconds; return(FormatedField(endMilliseconds, 3, match)); case "EndElapsedTime": TimeSpan endElapsedTime = subtitle.Times.Duration; return(FormatedField(endElapsedTime.TotalSeconds)); case "Text": SubtitleText subtitleText = (textType == SubtitleTextType.Text ? subtitle.Text : subtitle.Translation); string text = subtitleText.GetTrimLines(format.LineBreak); return(text.ToString()); case "Style": string style = format.StyleToString(subtitle.Style); return(style.ToString()); case "EndOfStyle": string endOfStyle = format.EndOfStyleToString(subtitle.Style); return(endOfStyle.ToString()); case "SubtitleNumber": return(FormatedField(subtitleNumber, match)); default: return(match.Value); } }