private void SetPlayerPosition(Chapter chap) { if (fpsChooserOut.Value != null) { chap = Chapter.ChangeChapterFPS(chap, pgc.FramesPerSecond, (double)fpsChooserOut.Value); } player.CurrentFrame = Util.ConvertTimecodeToFrameNumber(chap.Time, player.Framerate); }
private void addZoneButton_Click(object sender, System.EventArgs e) { TimeSpan ts = new TimeSpan(0); if (!GetTimeSpanFromString(startTime.Text, out ts)) { // invalid time input startTime.Focus(); startTime.SelectAll(); MessageBox.Show("Cannot parse the timecode you have entered.\nIt must be given in the hh:mm:ss.ccc format", "Incorrect timecode", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } GetStringFromTimeSpan(ts); int intIndex = 0; foreach (Chapter oChapter in pgc.Chapters) { if (oChapter.Time == ts) { return; } else if (oChapter.Time > ts) { break; } else { intIndex++; } } // create a new chapter Chapter c = new Chapter() { Time = ts, Name = GetChapterName(intIndex) }; if (fpsChooserIn.Value != null && fpsChooserOut.Value != null) { c = Chapter.ChangeChapterFPS(c, (double)fpsChooserOut.Value, (double)fpsChooserIn.Value); } pgc.Chapters.Insert(intIndex, c); ResetChapterView(intIndex); }
public void ChangeFps(double fps) { if (FramesPerSecond == 0 || FramesPerSecond == fps) { FramesPerSecond = fps; return; } for (int i = 0; i < Chapters.Count; i++) { Chapters[i] = Chapter.ChangeChapterFPS(Chapters[i], FramesPerSecond, fps); } double totalFrames = Duration.TotalSeconds * FramesPerSecond; Duration = new TimeSpan((long)Math.Round((totalFrames / fps) * TimeSpan.TicksPerSecond)); FramesPerSecond = fps; }
/// <summary> /// Recreates the chapter view /// </summary> private void ResetChapterView(int iSelectItem) { this.Cursor = Cursors.WaitCursor; try { if (iSelectItem < 0) { if (chapterListView.SelectedIndices.Count > 0) { iSelectItem = chapterListView.SelectedIndices[0]; } else { iSelectItem = 0; } } this.chapterListView.Items.Clear(); //fill list foreach (Chapter c in pgc.Chapters) { Chapter oChapter = c; string strTimeIn = GetStringFromTimeSpan(c.Time); string strTimeOut = strTimeIn; if (fpsChooserIn.Value != null && fpsChooserOut.Value != null && fpsChooserIn.Value != fpsChooserOut.Value) { oChapter = Chapter.ChangeChapterFPS(oChapter, (double)fpsChooserIn.Value, (double)fpsChooserOut.Value); strTimeOut = GetStringFromTimeSpan(oChapter.Time); } string frame = "N/A"; if (fpsChooserIn.Value.HasValue) { frame = (Util.ConvertTimecodeToFrameNumber(c.Time, (double)fpsChooserIn.Value)).ToString(); } ListViewItem item = new ListViewItem(new string[] { frame, strTimeIn, strTimeOut, c.Name }); chapterListView.Items.Add(item); if (item.Index % 2 != 0) { item.BackColor = Color.White; } else { item.BackColor = Color.FromArgb(255, 245, 245, 245); } } if (chapterListView.Items.Count > iSelectItem) { chapterListView.Items[iSelectItem].Selected = true; } } catch (Exception ex) { MessageBox.Show(ex.Message); } this.Cursor = Cursors.Default; }