private void btnSaveFiles_Click(object sender, EventArgs e) { try { SaveFiles(); } catch (Exception ex) { AcLogger.Log(ex, AcLogType.FileAndLogger); } }
private void btnGoToFrame_Click(object sender, EventArgs e) { try { if (fr.vidPlayer.VideoOpened && !fr.vidPlayer.VideoPlaying) { fr.vidPlayer.GetFrame(Convert.ToInt32(txtFrame.Text)); } } catch (Exception ex) { AcLogger.Log(ex, AcLogType.FileAndLogger); } }
private void btnUpdateProjectProperties_Click(object sender, EventArgs e) { try { fr.frpf.VideoFile = txtVideoFile.Text; fr.frpf.TimecodesFile = txtTimecodesFile.Text; fr.frpf.AviSynthOutputFile = txtAvisynthOutputFile.Text; fr.frpf.ProjectFile = txtProjectFile.Text; SaveFiles(); } catch (Exception ex) { AcLogger.Log(ex, AcLogType.FileAndLogger); } }
private void listChanges_SelectedIndexChanged(object sender, EventArgs e) { try { //Get the frame number of the change Int32 frameNum = 0; frameNum = Int32.Parse(listChanges.SelectedItem.ToString().Substring(0, listChanges.SelectedItem.ToString().IndexOf("->")).Trim()); //Go to the frame of the change fr.vidPlayer.GetFrame(frameNum); } catch (Exception ex) { AcLogger.Log(ex, AcLogType.FileAndLogger); } }
private void btnPreview_Click(object sender, EventArgs e) { try { //Make sure that files have the latest edits SaveFiles(); //Open the preview form (VideoPlayerForm) frmVideoPlayer vpf = new frmVideoPlayer(fr.frpf.AviSynthOutputFile); //Show the form vpf.Show(); } catch (Exception ex) { AcLogger.Log(ex, AcLogType.FileAndLogger); } }
private void btnDeleteFrame_Click(object sender, EventArgs e) { try { Boolean newOperation = true; //Check if this frame is already deleted or duplicated foreach (VideoFrame vf in fr.frpf.FrameList.FrameSections[0].FramesToDelete.FrameList) { if (vf.FrameNumber == fr.vidPlayer.VideoData.CurrentFrame) { throw new Exception("Frame is already deleted!"); } } //Check if this frame is already deleted or duplicated foreach (VideoFrame vf in fr.frpf.FrameList.FrameSections[0].FramesToDuplicate.FrameList) { if (vf.FrameNumber == fr.vidPlayer.VideoData.CurrentFrame) { vf.ProcessType = FrameProcessType.ToDelete; newOperation = false; break; } } if (newOperation) { //Add current frame to the deleted ones fr.AddDelete(fr.vidPlayer.VideoData.CurrentFrame); } //Check if auto-commit is checked to save files AutoCommit(); //Add change to the list UpdateListChanges(); //Refresh the GUI UpdateCurrentFrameStatus(); } catch (Exception ex) { AcLogger.Log(ex, AcLogType.FileAndLogger); } }
private void VideoPlayerForm_FormClosing(object sender, FormClosingEventArgs e) { try { if (videoPlaying) { videoPlaying = false; videoPlayThread.Join(); videoPlayThread = null; } if (picVideo.Image != null) { picVideo.Image.Dispose(); picVideo.Image = null; } if (!picVideo.IsDisposed) { picVideo.Dispose(); } if (avs != null) { avs.Dispose(); } if (vpcf != null && !vpcf.IsDisposed) { vpcf.Dispose(); } if (sef != null && !sef.IsDisposed) { sef.DisableFromVideoBtns(); } GC.Collect(); } catch (Exception ex) { Debug.WriteLine(ex); AcLogger.Log(ex, AcLogType.Logger); } }
private void playVideo() { if (fr.vidPlayer.VideoOpened) { try { Int32 frameDuration = Convert.ToInt32((Convert.ToDouble(fr.vidPlayer.VideoData.Avs.Clip.Rated) / Convert.ToDouble(fr.vidPlayer.VideoData.Avs.Clip.Raten)) * 1000.0); Int32 sleepTime = 0; Stopwatch actime = new Stopwatch(); while (fr.vidPlayer.VideoData.CurrentFrame <= fr.vidPlayer.VideoData.Avs.Clip.NumberOfFrames - 1 && fr.vidPlayer.VideoPlaying) { actime.Start(); fr.vidPlayer.GetNextFrame(); actime.Stop(); sleepTime = Convert.ToInt32(frameDuration - actime.ElapsedMilliseconds); if (sleepTime < 0) { sleepTime = 0; } Thread.Sleep(sleepTime); } //Check if stop was pressed if (fr.vidPlayer.VideoData.CurrentFrame > trackVideo.Maximum) { //The video has reached the end frame btnPlayVideo.Text = "Play"; fr.vidPlayer.VideoPlaying = false; } } catch (Exception ex) { AcLogger.Log(new AcException("Error playing video!", ex), AcLogType.FileAndLogger); } } }
private void btnDeleteChange_Click(object sender, EventArgs e) { try { //Check if an item is selected if (listChanges.SelectedIndex > -1) { //Get the frame number of the change Int32 frameNum = 0; frameNum = Int32.Parse(listChanges.SelectedItem.ToString().Substring(0, listChanges.SelectedItem.ToString().IndexOf("->")).Trim()); //Check if the change is for deleted or duplicated frame if (listChanges.SelectedItem.ToString().Contains("Delete")) { fr.RemoveDelete(frameNum); } else if (listChanges.SelectedItem.ToString().Contains("Duplicate")) { fr.RemoveDuplicate(frameNum); } //Remove the change from the list UpdateListChanges(); //Check if auto-commit is checked to save files AutoCommit(); //Refresh the GUI UpdateCurrentFrameStatus(); } } catch (Exception ex) { AcLogger.Log(ex, AcLogType.FileAndLogger); } }
/// <summary> /// Shows an Exception message to the user, Debug writes the Exception and Logs to the file and logger /// </summary> /// <param name="errorException">The Exception to be shown</param> /// <param name="errorTitle">The title of the Exception message</param> public void ShowExceptionMessage(Exception errorException, String errorTitle = "An error has occured!") { Debug.WriteLine(errorException); AcLogger.Log(errorException, AcLogType.FileAndLogger); ShowErrorMessage(errorException.Message); }
private void FrameRestorationForm_KeyDown(object sender, KeyEventArgs e) { try { if (fr.vidPlayer.VideoOpened) { if (e.KeyCode == Keys.Right) { if (e.Modifiers == Keys.Control) { if (fr.vidPlayer.VideoData.CurrentFrame + 10 >= fr.vidPlayer.VideoData.Avs.Clip.NumberOfFrames) { fr.vidPlayer.GetLastFrame(); refreshGUI(); //trackVideo.Value = vidPlayer.VideoData.Avs.Clip.NumberOfFrames - 1; return; } else { fr.vidPlayer.GetNextFrame(10); refreshGUI(); //trackVideo.Value += 10; return; } } else { if (fr.vidPlayer.VideoData.CurrentFrame + 1 >= fr.vidPlayer.VideoData.Avs.Clip.NumberOfFrames) { fr.vidPlayer.GetLastFrame(); refreshGUI(); //trackVideo.Value = vidPlayer.VideoData.Avs.Clip.NumberOfFrames - 1; return; } else { fr.vidPlayer.GetNextFrame(); refreshGUI(); //trackVideo.Value++; return; } } } else if (e.KeyCode == Keys.Left) { if (e.Modifiers == Keys.Control) { if (fr.vidPlayer.VideoData.CurrentFrame - 10 < 0) { fr.vidPlayer.GetFrame(0); refreshGUI(); //trackVideo.Value = 0; return; } else { fr.vidPlayer.GetPrevFrame(10); refreshGUI(); //trackVideo.Value -= 10; return; } } else { if (fr.vidPlayer.VideoData.CurrentFrame - 1 < 0) { fr.vidPlayer.GetFrame(0); refreshGUI(); //trackVideo.Value = 0; return; } else { fr.vidPlayer.GetPrevFrame(); refreshGUI(); //trackVideo.Value--; return; } } } else if (e.KeyCode == Keys.F2) { //btnReload_Click(null, null); return; } else if (e.KeyCode == Keys.G && e.Modifiers == Keys.Control) { String result = AcInputBox.Show("Enter frame number :", "Enter frame number", ""); if (result != null) { txtFrame.Text = result; } btnGoToFrame_Click(null, null); refreshGUI(); return; } else if (e.KeyCode == Keys.Space) { btnPlayVideo_Click(null, null); return; } else if (e.KeyCode == Keys.D1 || e.KeyCode == Keys.Subtract || e.KeyCode == Keys.Z) { btnDeleteFrame_Click(null, null); refreshGUI(); } else if (e.KeyCode == Keys.D2 || e.KeyCode == Keys.Add || e.KeyCode == Keys.X) { btnDuplicate_Click(null, null); refreshGUI(); } } } catch (Exception ex) { AcLogger.Log(ex, AcLogType.FileAndLogger); } }
private void btnStart_Click(object sender, EventArgs e) { try { Boolean useFakeTimecodes = false; if (tabCtrlFiles.SelectedTab == tabPageProject) { //Check if project file is provided if (txtProjectFile.Text == string.Empty) { throw new Exception("Please provide with a project file first!"); } //Open the project file fr.frpf = new FrameRestorationProjectFile(txtProjectFile.Text); txtVideoFile.Text = fr.frpf.VideoFile; txtTimecodesFile.Text = fr.frpf.TimecodesFile; txtAvisynthOutputFile.Text = fr.frpf.AviSynthOutputFile; if (fr.frpf.TimecodesFile == String.Empty) { useFakeTimecodes = true; } else { useFakeTimecodes = fr.frpf.UseFakeTimecodes; } //fr.vidPlayer.OpenVideo(fr.frpf.VideoFile); if (useFakeTimecodes) { //Load fake timecodes fr.frpf.FrameList.CreateFakeTimecodes(fr.vidPlayer.VideoData.Avs.Clip.NumberOfFrames, Convert.ToDecimal(fr.vidPlayer.VideoData.Avs.Clip.Rate)); //Create a new section VideoFrameSection vfs = new VideoFrameSection("Whole_Video", 0, fr.frpf.FrameList.Count - 1); fr.frpf.FrameList.AddSection(vfs); } trackVideo.Maximum = fr.vidPlayer.VideoData.Avs.Clip.NumberOfFrames - 1; trackVideo.Minimum = 0; fr.vidPlayer.GetFrame(0); } else if (tabCtrlFiles.SelectedTab == tabPageFiles) { //Assume new project //Check if video file exists if (!File.Exists(txtVideoFile.Text)) { throw new AcException("Error creating project! The video file provided does not exist!"); } //Check if timecodes exist if (!File.Exists(txtTimecodesFile.Text)) { if (AcMessageBox.Show("Do you want to use fake timecodes?", "No timecodes found!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { useFakeTimecodes = true; } else { throw new AcException("Error creating project! The Timecodes file provided does not exist!"); } } //Create the new project fr.frpf = new FrameRestorationProjectFile(); fr.frpf.UseFakeTimecodes = useFakeTimecodes; //Load the video //fr.vidPlayer.OpenVideo(txtVideoFile.Text); trackVideo.Maximum = fr.vidPlayer.VideoData.Avs.Clip.NumberOfFrames - 1; trackVideo.Minimum = 0; //Check for fake timecodes if (useFakeTimecodes) { //Load fake timecodes fr.frpf.FrameList.CreateFakeTimecodes(fr.vidPlayer.VideoData.Avs.Clip.NumberOfFrames, Convert.ToDecimal(fr.vidPlayer.VideoData.Avs.Clip.Rate)); } else { //Load the timecodes fr.frpf.FrameList.LoadTimecodes(txtTimecodesFile.Text, false, 3); } //Add the section fr.frpf.FrameList.AddSection(new VideoFrameSection("Whole_Video", 0, fr.vidPlayer.VideoData.Avs.Clip.NumberOfFrames - 1)); //Check the validity of timecodes file if (fr.frpf.FrameList.Count == 0) { AcLogger.Log(new AcException("Error creating project! Timecodes file didn't contain any frames!"), AcLogType.FileAndLogger); fr.vidPlayer.Dispose(); return; } //Check that timecodes and video files match if (fr.vidPlayer.VideoData.Avs.Clip.NumberOfFrames != fr.frpf.FrameList.Count) { AcLogger.Log(new AcException("Error creating project! Timecodes file doesn't match video!"), AcLogType.FileAndLogger); fr.vidPlayer.Dispose(); return; } //Update the project data fr.frpf.VideoFile = txtVideoFile.Text; fr.frpf.TimecodesFile = txtTimecodesFile.Text; //Prompt the user for a project file name String filename = ShowSaveFileDialog("Select a project file to save...", "", "*.frproj (Frame Restoration Project)|*.frproj"); if (filename == null) { return; } fr.frpf.ProjectFile = filename; //Create the new project file fr.WriteProject(); txtProjectFile.Text = filename; //Get the first form fr.vidPlayer.GetFrame(0); } //Enable the controls btnDeleteChange.Enabled = true; btnDeleteFrame.Enabled = true; btnDuplicateFrame.Enabled = true; btnPreview.Enabled = true; btnSaveFiles.Enabled = true; btnUpdateProjectProperties.Enabled = true; checkAutoCommit.Enabled = true; checkZoom.Enabled = true; //refresh the list UpdateListChanges(); } catch (Exception ex) { AcLogger.Log(new AcException("Error creating project!", ex), AcLogType.FileAndLogger); Debug.WriteLine(ex.StackTrace); } }