Example #1
0
        public bool Add(SyncPoint syncPoint)
        {
            bool willReplace = Contains(syncPoint.SubtitleNumber);

            syncPoints[syncPoint.SubtitleNumber] = syncPoint;
            return(willReplace);
        }
Example #2
0
	/* Public methods */

	public int Add (SyncPoint syncPoint) {
		bool didReplace = collection.Add(syncPoint);
		int index = collection.IndexOf(syncPoint);
		if (didReplace) {
			Replace(index, syncPoint); //Replace existing
			return index;
		}
		else if (collection[collection.Count - 1].SubtitleNumber == syncPoint.SubtitleNumber) {
			Append(syncPoint); //Append to the end
			return collection.Count - 1;
		}
		else {
			Insert(index, syncPoint); //Insert in position, not replacing
			return index;
		}
	}
Example #3
0
	public int CompareCurrentTo (SyncPoint otherSyncPoint) {
		return current.CompareTo(otherSyncPoint.Current);
	}
 public int IndexOf(SyncPoint syncPoint)
 {
     return(syncPoints.IndexOfKey(syncPoint.SubtitleNumber));
 }
Example #5
0
	private void Insert (int index, SyncPoint syncPoint) {
		model.SetValue(model.Insert(index), 0, syncPoint);
	}
Example #6
0
	private void Append (SyncPoint syncPoint) {
		model.AppendValues(syncPoint);
	}
Example #7
0
	private void Replace (int index, SyncPoint syncPoint) {
		TreeIter iter;
		model.GetIterFromString(out iter, index.ToString());
		model.SetValue(iter, 0, syncPoint);
	}
Example #8
0
	public static bool Sync (Subtitles subtitles, SyncPoint start, SyncPoint end, bool syncLast) {
		return Sync(subtitles, start.SubtitleNumber, start.Correct.Time, end.SubtitleNumber, end.Correct.Time, syncLast);
	}
Example #9
0
	public static bool AreSyncPointsValid (Subtitles subtitles, SyncPoint start, SyncPoint end) {
		return AreSyncArgsValid(subtitles, start.SubtitleNumber, start.Correct.Time, end.SubtitleNumber, end.Correct.Time)
			&& AreSyncArgsValid(subtitles, start.SubtitleNumber, start.Correct.Frame, end.SubtitleNumber, end.Correct.Frame);
	}
Example #10
0
	public bool Add (SyncPoint syncPoint) {
		bool willReplace = Contains(syncPoint.SubtitleNumber);
		syncPoints[syncPoint.SubtitleNumber] = syncPoint;
		return willReplace;
	}
Example #11
0
	public int IndexOf (SyncPoint syncPoint) {
		return syncPoints.IndexOfKey(syncPoint.SubtitleNumber);
	}
Example #12
0
 public int CompareCurrentTo(SyncPoint otherSyncPoint)
 {
     return(current.CompareTo(otherSyncPoint.Current));
 }
	private void OnAdd (object o, EventArgs args) {
		/* Check if document and video are loaded */
		if (!(Base.IsDocumentLoaded && Base.Ui.Video.IsLoaded))
			return;

		/* Get selected subtitle */
		TreePath path = Base.Ui.View.Selection.Path;
		if (path == null)
			return;

		int subtitleNumber = Core.Util.PathToInt(path);
		Subtitle subtitle = Base.Ui.View.Selection.Subtitle;

		/* Get current start */
		Timing currentTiming = new Timing(subtitle.Frames.Start, subtitle.Times.Start);

		/* Get correct start from video */
		Timing correctTiming = new Timing(Base.Ui.Video.Position.CurrentFrames, Base.Ui.Video.Position.CurrentTime);

		/* Create and add the sync point */
		SyncPoint syncPoint = new SyncPoint(subtitleNumber, currentTiming, correctTiming);
		int syncPointIndex = syncPoints.Add(syncPoint);
		TreePath syncPointPath = Core.Util.IntToPath(syncPointIndex);
		SelectPath(syncPointPath);

		UpdateFromSyncPointCountChanged();
	}