From 0bf7979f9cf444c737521b889d9c4eaba15d3726 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bellai=20=C3=81d=C3=A1m?= Date: Thu, 5 Oct 2017 21:09:27 +0000 Subject: [PATCH] git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30544 --- client/DxPlay/PlayerForm.Designer.cs | 1 + client/DxPlay/PlayerForm.cs | 143 +++++++++++++++++---------- 2 files changed, 92 insertions(+), 52 deletions(-) diff --git a/client/DxPlay/PlayerForm.Designer.cs b/client/DxPlay/PlayerForm.Designer.cs index d1875909..1d320474 100644 --- a/client/DxPlay/PlayerForm.Designer.cs +++ b/client/DxPlay/PlayerForm.Designer.cs @@ -300,6 +300,7 @@ namespace DxPlay { this.dgSegments.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dgSegments.Size = new System.Drawing.Size(257, 521); this.dgSegments.TabIndex = 1; + this.dgSegments.RowsAdded += new System.Windows.Forms.DataGridViewRowsAddedEventHandler(this.dgSegments_RowsAdded); // // menuButtonSegmentActions // diff --git a/client/DxPlay/PlayerForm.cs b/client/DxPlay/PlayerForm.cs index 9834d16b..1d4b9ca0 100644 --- a/client/DxPlay/PlayerForm.cs +++ b/client/DxPlay/PlayerForm.cs @@ -274,8 +274,14 @@ namespace DxPlay { } return result; } - + private void PlayerForm_FormClosing(object sender, FormClosingEventArgs e) { + foreach (MovieSegment segment in segments) + if (segment.TCOut == null) { + e.Cancel = true; + return; + } + if (m_play != null) { m_play.Stop(); m_play.Dispose(); @@ -310,12 +316,6 @@ namespace DxPlay { TCOut = new Timecode(m_mediaDescription.FirstFrame, m_mediaDescription.Duration) }; segments.Add(segment); - //if (outro == null) - // segments.Add(segment); - //else { - // int index = segments.Count - 2; - // segments.Insert(index, segment); - //} } private void OnDeleteSegmentClick(object sender, EventArgs e) { @@ -334,56 +334,98 @@ namespace DxPlay { private void OnActualPositionToTCInToolStripMenuItem1Click(object sender, EventArgs e) { MovieSegment currentSegment = GetCurrentSegment(); if (currentSegment != null) { + if (currentSegment.TCIn != null) { DialogResult dialogResult = MessageBox.Show("Biztos felül akarja írni az belépõt?", "Belépõ felülírása", MessageBoxButtons.YesNo); - if (dialogResult == DialogResult.Yes) - currentSegment.TCIn = m_play.CurrentTC; - } else - currentSegment.TCIn = m_play.CurrentTC; + if (dialogResult == DialogResult.Yes) { + if (IsTCInBeforeTCOut(m_play.CurrentTC, currentSegment.TCOut)) { + Timecode actual = new Timecode(); + actual.Set(m_play.CurrentTC.Frames); + currentSegment.TCIn = actual; + } else { + MessageBox.Show("A kilépõ a belépõ elõtt van!", "Hiba"); + //így kell? + currentSegment.TCIn = null; + //vagy így? + //currentSegment.TCIn = new Timecode(); + } + } + } else { + Timecode actual = new Timecode(m_play.CurrentTC); + currentSegment.TCIn = actual; + } + } else { + MovieSegment segment = new MovieSegment() { + TCIn = new Timecode(m_mediaDescription.FirstFrame), + //ez kell-e? + //TCOut = new Timecode(m_mediaDescription.FirstFrame, m_mediaDescription.Duration) + }; + segments.Add(segment); } - - - //if (intro != null) { - // DialogResult dialogResult = MessageBox.Show("Biztos felül akarja írni az belépõt?", "Belépõ felülírása", MessageBoxButtons.YesNo); - // if (dialogResult == DialogResult.Yes) { - // segments.RemoveAt(0); - // CreateAndAddIntroToSegments(); - // } - //} else - // CreateAndAddIntroToSegments(); + dgSegments.DataSource = bsSegments; } - //private void CreateAndAddIntroToSegments() { - // intro = new MovieSegment() { - // TCIn = new Timecode(m_mediaDescription.FirstFrame), - // TCOut = m_play.CurrentTC - // }; - // segments.Insert(0, intro); - //} - private void OnActualPositionToTCOutToolStripMenuItem1Click(object sender, EventArgs e) { MovieSegment currentSegment = GetCurrentSegment(); if (currentSegment != null) { if (currentSegment.TCOut != null) { DialogResult dialogResult = MessageBox.Show("Biztos felül akarja írni a kilépõt?", "Kilépõ felülírása", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { - currentSegment.TCOut = m_play.CurrentTC; + if (IsTCInBeforeTCOut(currentSegment.TCIn, m_play.CurrentTC)) { + Timecode actual = new Timecode(); + actual.Set(m_play.CurrentTC.Frames); + currentSegment.TCOut = actual; + } else { + MessageBox.Show("A kilépõ a belépõ elõtt van!", "Hiba"); + //így kell? + currentSegment.TCIn = null; + //vagy így? + //currentSegment.TCIn = new Timecode(); + } } - } else - currentSegment.TCOut = m_play.CurrentTC; + } else { + Timecode actual = new Timecode(m_play.CurrentTC); + currentSegment.TCOut = actual; + } + } else { + MovieSegment segment = new MovieSegment() { + //ez kell-e? + //TCIn = new Timecode(m_mediaDescription.FirstFrame), + TCOut = new Timecode(m_mediaDescription.FirstFrame, m_mediaDescription.Duration) + }; + segments.Add(segment); } + } + private bool IsTCInBeforeTCOut(Timecode tcIn, Timecode tcOut) { + if (tcIn == null || tcOut == null) + return true; + string tcInString = tcIn.ToString(); + string tcOutString = tcOut.ToString(); + string inHour = tcInString.Substring(0, 2); + string outHour = tcOutString.Substring(0, 2); + if (Int32.Parse(outHour) < Int32.Parse(inHour)) + return false; + else if (Int32.Parse(outHour) > Int32.Parse(inHour)) + return true; + string inMinute = tcInString.Substring(3, 2); + string outMinute = tcOutString.Substring(3, 2); + if (Int32.Parse(outMinute) < Int32.Parse(inMinute)) + return false; + else if (Int32.Parse(outMinute) > Int32.Parse(inMinute)) + return true; + string inSec = tcInString.Substring(6, 2); + string outSec = tcOutString.Substring(6, 2); + if (Int32.Parse(outSec) < Int32.Parse(inSec)) + return false; + else if (Int32.Parse(outSec) > Int32.Parse(inSec)) + return true; + string inFrame = tcInString.Substring(9, 2); + string outFrame = tcOutString.Substring(9, 2); + if (Int32.Parse(outFrame) <= Int32.Parse(inFrame)) + return false; - - //if (outro != null) { - // DialogResult dialogResult = MessageBox.Show("Biztos felül akarja írni a kilépõt?", "Kilépõ felülírása", MessageBoxButtons.YesNo); - // if (dialogResult == DialogResult.Yes) { - // int outroIndex = segments.Count - 1; - // segments.RemoveAt(outroIndex); - // CreateAndAddOutroToSegments(); - // } - //} else - // CreateAndAddOutroToSegments(); + return true; } private MovieSegment GetCurrentSegment() { @@ -398,15 +440,6 @@ namespace DxPlay { return null; } - //private void CreateAndAddOutroToSegments() { - // outro = new MovieSegment() { - // TCIn = m_play.CurrentTC, - // TCOut = new Timecode(m_play.CurrentTC, m_play.MediaDescription.Duration) - // }; - // int index = segments.Count; - // segments.Insert(index, outro); - //} - private void OnSplitSegmentAtCurrentPositionClick(object sender, EventArgs e) { MovieSegment segment = segments.Where(s => m_play.CurrentTC.Frames > s.TCIn.Frames && m_play.CurrentTC.Frames < s.TCOut.Frames).FirstOrDefault(); @@ -426,8 +459,14 @@ namespace DxPlay { }; hSegment.TCIn.Set(m_play.CurrentTC.ZeroBasedFrames + 1); segments.Add(hSegment); - } + private void dgSegments_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e) { + DataGridViewColumnCollection cols = dgSegments.Columns; + if (cols.Count >= 2) { + cols[0].ReadOnly = true; + cols[1].ReadOnly = true; + } + } } } -- 2.54.0