/// <summary> /// Shows a question to the user and returns the answer (Yes, No, Cancel) /// </summary> /// <param name="questionMessage">The question text</param> /// <param name="questionTitle">The title of the question</param> /// <param name="showCancel">Whether to show Cancel button or not</param> /// <returns>The answer of the user</returns> public DialogResult ShowQuestion(String questionMessage, String questionTitle = "Are you sure?", Boolean showCancel = true) { MessageBoxButtons btns = MessageBoxButtons.YesNoCancel; if (!showCancel) { btns = MessageBoxButtons.YesNo; } return(AcMessageBox.Show(questionMessage, questionTitle, btns, MessageBoxIcon.Question)); }
private void btnInfo_Click(object sender, EventArgs e) { try { using (AcToolsLibrary.Core.MediaInfo.AcMediaInfo mi = new AcToolsLibrary.Core.MediaInfo.AcMediaInfo(txtVideoFile.Text)) { AcMessageBox.Show(mi.InfoCustom, "Video Info", MessageBoxIcon.Information); } if (videoOpened) { StringBuilder strb = new StringBuilder(); strb.AppendFormat("Video Resolution : {0}x{1}", avs.Clip.VideoWidth, avs.Clip.VideoHeight); strb.AppendLine(); strb.AppendFormat("Video Framerate : {0} ({1}/{2})", (Convert.ToDecimal(avs.Clip.Raten) / Convert.ToDecimal(avs.Clip.Rated)).ToString("###.000"), avs.Clip.Raten, avs.Clip.Rated); strb.AppendLine(); strb.AppendFormat("Total frames : {0}", avs.Clip.NumberOfFrames); strb.AppendLine(); strb.AppendFormat("Total duration : {0}", VideoFrame.FrameTimeFromFrameNumber(avs.Clip.NumberOfFrames, Convert.ToDecimal(avs.Clip.Raten) / Convert.ToDecimal(avs.Clip.Rated), FrameFromType.FromFrameRate)); strb.AppendLine(); strb.AppendFormat("Colorspace : {0}", Enum.GetName(typeof(AviSynthColorspace), avs.Clip.OriginalColorspace)); strb.AppendLine(); strb.AppendFormat("Pixel type : {0}", Enum.GetName(typeof(AviSynthColorspace), avs.Clip.PixelType)); strb.AppendLine(); strb.AppendFormat("Aspect ratio : {0}/{1}", avs.Clip.aspectn, avs.Clip.aspectd); Clipboard.SetDataObject(strb.ToString()); AcMessageBox.Show(strb.ToString(), "Video Info", MessageBoxIcon.Information); } } catch (Exception ex) { ShowExceptionMessage(ex); } }
/// <summary> /// Shows a question as a warning to the user and returns the answer (Yes, No, Cancel) /// </summary> /// <param name="questionMessage">The question text</param> /// <param name="questionTitle">The title of the question</param> /// <returns>The answer of the user</returns> public DialogResult ShowWarningQuestion(String questionMessage, String questionTitle = "Warning!") { return(AcMessageBox.Show(questionMessage, questionTitle, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning)); }
/// <summary> /// Shows a warning message /// </summary> /// <param name="warningMessage">The warning message</param> /// <param name="warningTitle">The title of the warning message</param> public void ShowWarningMessage(String warningMessage, String warningTitle = "Warning!") { AcMessageBox.Show(String.Format("Warning!\r\n\r\n{0}", warningMessage), warningTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); }
/// <summary> /// Shows an information message to the user /// </summary> /// <param name="infoMessage">The information message</param> /// <param name="infoTitle">The title of the information message</param> public void ShowInformationMessage(String infoMessage, String infoTitle = "Information") { AcMessageBox.Show(infoMessage, infoTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); }
/// <summary> /// Shows a suceess message to the user /// </summary> /// <param name="successMessage">The success message</param> /// <param name="successTitle">The title of the success message</param> public void ShowSuccessMessage(String successMessage, String successTitle = "Success!") { AcMessageBox.Show(successMessage, successTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); }
/// <summary> /// Show an error message to the user /// </summary> /// <param name="errorMessage">The error message</param> /// <param name="errorTitle">The title of the error message</param> public void ShowErrorMessage(String errorMessage, String errorTitle = "An error has occured!") { AcMessageBox.Show(String.Format("An error has occured!\r\n\r\n{0}", errorMessage), errorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); }
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); } }
public override void UpdateGUI(Object obj) { try { VideoPlayerUpdateData vpud = (VideoPlayerUpdateData)obj; IAsyncResult ar; ar = picVideoFrameCurrent.BeginInvoke(new UpdatePicVideoCurrentDelegate(this.UpdatePicVideoCurrent), new Object[] { vpud.VideoFrameImage }); ar = txtFrame.BeginInvoke(new UpdateTxtFrameDelegate(this.UpdateTxtFrame), new Object[] { vpud.CurrentFrame.ToString() }); txtFrame.EndInvoke(ar); Decimal frameRate = Convert.ToDecimal(vpud.Avs.Clip.Raten) / Convert.ToDecimal(vpud.Avs.Clip.Rated); ar = txtCurrentTime.BeginInvoke(new UpdateTxtCurrentTimeDelegate(this.UpdateTxtCurrentTime), new Object[] { VideoFrame.FrameTimeFromFrameNumber(vpud.CurrentFrame, frameRate, FrameFromType.FromFrameRate) }); fromUpdateGUI = true; trackVideo.Invoke(new UpdateTrackVideoDelegate(this.UpdateTrackVideo), new Object[] { vpud.CurrentFrame }); fromUpdateGUI = false; ar = txtVideoFrameCurrent.BeginInvoke(new UpdateTxtVideoFrameCurrentDelegate(this.UpdateTxtVideoFrameCurrent), new Object[] { vpud.CurrentFrame.ToString() }); ar = txtStatusCurrent.BeginInvoke(new UpdateTxtStatusCurrentDelegate(this.UpdateTxtStatusCurrent), new Object[] { Enum.GetName(typeof(FrameProcessType), fr.frpf.FrameList.FrameList[vpud.CurrentFrame].ProcessType) }); if (vpud.CurrentFrame == 0) { ar = txtVideoFramePrevious.BeginInvoke(new UpdateTxtVideoFramePreviousDelegate(this.UpdateTxtVideoFramePrevious), new Object[] { "-" }); ar = txtStatusPrevious.BeginInvoke(new UpdateTxtStatusPreviousDelegate(this.UpdateTxtStatusPrevious), new Object[] { "-" }); ar = picVideoFramePrevious.BeginInvoke(new UpdatePicVideoPreviousDelegate(this.UpdatePicVideoPrevious), new Object[] { vpud.VideoFrameImagePrevious }); ar = txtVideoFrameNext.BeginInvoke(new UpdateTxtVideoFrameNextDelegate(this.UpdateTxtVideoFrameNext), new Object[] { (vpud.CurrentFrame + 1).ToString() }); ar = txtStatusNext.BeginInvoke(new UpdateTxtStatusNextDelegate(this.UpdateTxtStatusNext), new Object[] { Enum.GetName(typeof(FrameProcessType), fr.frpf.FrameList.FrameList[vpud.CurrentFrame + 1].ProcessType) }); ar = picVideoFrameNext.BeginInvoke(new UpdatePicVideoNextDelegate(this.UpdatePicVideoNext), new Object[] { vpud.VideoFrameImageNext }); } else if (vpud.CurrentFrame == vpud.Avs.Clip.NumberOfFrames - 1) { ar = txtVideoFramePrevious.BeginInvoke(new UpdateTxtVideoFramePreviousDelegate(this.UpdateTxtVideoFramePrevious), new Object[] { (vpud.CurrentFrame - 1).ToString() }); ar = txtStatusPrevious.BeginInvoke(new UpdateTxtStatusPreviousDelegate(this.UpdateTxtStatusPrevious), new Object[] { Enum.GetName(typeof(FrameProcessType), fr.frpf.FrameList.FrameList[vpud.CurrentFrame - 1].ProcessType) }); ar = picVideoFramePrevious.BeginInvoke(new UpdatePicVideoPreviousDelegate(this.UpdatePicVideoPrevious), new Object[] { vpud.VideoFrameImagePrevious }); ar = txtVideoFrameNext.BeginInvoke(new UpdateTxtVideoFrameNextDelegate(this.UpdateTxtVideoFrameNext), new Object[] { "-" }); ar = txtStatusNext.BeginInvoke(new UpdateTxtStatusNextDelegate(this.UpdateTxtStatusNext), new Object[] { "-" }); ar = picVideoFrameNext.BeginInvoke(new UpdatePicVideoNextDelegate(this.UpdatePicVideoNext), new Object[] { vpud.VideoFrameImageNext }); } else { ar = txtVideoFramePrevious.BeginInvoke(new UpdateTxtVideoFramePreviousDelegate(this.UpdateTxtVideoFramePrevious), new Object[] { (vpud.CurrentFrame - 1).ToString() }); ar = txtStatusPrevious.BeginInvoke(new UpdateTxtStatusPreviousDelegate(this.UpdateTxtStatusPrevious), new Object[] { Enum.GetName(typeof(FrameProcessType), fr.frpf.FrameList.FrameList[vpud.CurrentFrame - 1].ProcessType) }); ar = picVideoFramePrevious.BeginInvoke(new UpdatePicVideoPreviousDelegate(this.UpdatePicVideoPrevious), new Object[] { vpud.VideoFrameImagePrevious }); ar = txtVideoFrameNext.BeginInvoke(new UpdateTxtVideoFrameNextDelegate(this.UpdateTxtVideoFrameNext), new Object[] { (vpud.CurrentFrame + 1).ToString() }); ar = txtStatusNext.BeginInvoke(new UpdateTxtStatusNextDelegate(this.UpdateTxtStatusNext), new Object[] { Enum.GetName(typeof(FrameProcessType), fr.frpf.FrameList.FrameList[vpud.CurrentFrame + 1].ProcessType) }); ar = picVideoFrameNext.BeginInvoke(new UpdatePicVideoNextDelegate(this.UpdatePicVideoNext), new Object[] { vpud.VideoFrameImageNext }); } } catch (Exception ex) { AcMessageBox.Show(ex.Message, "Error!", MessageBoxIcon.Error); } }