private void SelectionFindRegion() { try { //Options.ScriptOptionCollection options = Options.GetOptions("Find Region"); var myPrompt = new FormSimplePrompt { tbUserData = { Text = ScriptOptions.GetValue(SelectionStrings.FindRegionKeyName, SelectionStrings.FindRegionLastString, "") }, Text = "Find Region", lblPrompt = { Text = "Search for:" }, lblDescription = { Text = "Partial name of region to find" } }; if (myPrompt.ShowDialog() == DialogResult.OK) { Region selRegion = myVegas.GetSelectedRegion(); Timecode startTime = (selRegion != null) ? selRegion.Position : Timecode.FromSeconds(0); Region bestRegion = myVegas.Project.FindRegion(myPrompt.tbUserData.Text, startTime); if (bestRegion == null) { return; } myVegas.Transport.SelectionStart = bestRegion.Position; myVegas.Transport.SelectionLength = bestRegion.Length; ScriptOptions.SetValue(SelectionStrings.FindRegionKeyName, SelectionStrings.FindRegionLastString, myPrompt.tbUserData.Text); } } catch (Exception e) { MessageBox.Show(e.ToString()); } }
private void renameToolStripMenuItem_Click(object sender, EventArgs e) { List <Media> selectedMedia = GetSelectedMedia(); using (var undo = new UndoBlock("Rename media")) { foreach (Media media in selectedMedia) { var MovePrompt = new FormSimplePrompt("Enter destination", "Enter the target filename", "Note: you can enter an existing file.") { tbUserData = { Text = Path.GetFileName(media.FilePath) } }; DialogResult rslt = MovePrompt.ShowDialog(); if (rslt != DialogResult.OK) { continue; } string target = MovePrompt.tbUserData.Text; if (File.Exists(target)) { DialogResult RetargetRslt = MessageBox.Show( "Re-target this media to the specified file? If the file content differs, this may destabilize your project.", "Target file exists", MessageBoxButtons.YesNo); if (RetargetRslt != DialogResult.Yes) { continue; } } target = ResolveFilePath(media.FilePath, target); #if DEBUG DialogResult go = MessageBox.Show(String.Format("RENAME:\n{0}\nTO\n{1}", media.FilePath, target), "Do it?", MessageBoxButtons.YesNo); if (go != DialogResult.Yes) { continue; } #endif RenameMedia(media, target); } } PopulateMediaListItems(); }
private void EventPitchSet_Invoke(object sender, EventArgs e) { var prompt = new FormSimplePrompt("Enter pitch", "Pitch", "Enter the pitch in semitones"); prompt.OnEvalInput += ParsePitchString; if (prompt.ShowDialog() == DialogResult.Cancel) { return; } decimal pitch; bool success = decimal.TryParse(ParsePitchString(prompt.tbUserData.Text), out pitch); if (!success) { return; } EventPitchChangeSet(pitch); }
private void EventPropertiesNormGainSet_Invoked(object sender, EventArgs e) { List <TrackEvent> selected = myVegas.Project.GetSelectedEvents(); if (selected.Count == 0) { return; } using (var undo = new UndoBlock("Set Normalization Gain")) { var dlg = new FormSimplePrompt("Enter gain", "Enter the gain in decibels", "Enter a valid decimal number."); dlg.OnEvalInput += delegate(String Text) { float tryGain; if (float.TryParse(Text, out tryGain)) { return(tryGain.ToString()); } return("Enter a valid decimal number."); }; DialogResult rslt = dlg.ShowDialog(); if (rslt != DialogResult.OK) { return; } float gain; if (!float.TryParse(dlg.tbUserData.Text, out gain)) { return; } foreach (TrackEvent ev in selected) { if (ev.IsAudio()) { var aev = ev as AudioEvent; aev.SetNormalizationGain(gain); } } } }
private void CopyToolStripMenuItem_Click(object sender, EventArgs e) { MediaPool pool = MyVegas.Project.MediaPool; List <Media> selectedMedia = GetSelectedMedia(); using (var undo = new UndoBlock("Copy media to folder")) { var MovePrompt = new FormSimplePrompt("Enter destination", "Enter the destination folder here", "Non-existing folder will be created."); DialogResult rslt = MovePrompt.ShowDialog(); if (rslt != DialogResult.OK) { return; } string targetPath = ResolveFolderPath(MovePrompt.tbUserData.Text); if (targetPath == string.Empty) { MessageBox.Show("Weird path supplied. Please enter a path in this format: C:\\Path\\"); return; } // show zee bar! bool YesToAll = false; bool NoToAll = false; var progress = new FormProgressDialog("Copying files..."); progress.SetBounds(0, selectedMedia.Count); progress.Show(); foreach (Media media in selectedMedia) { progress.PerformStep(); string finalFileName = targetPath + Path.DirectorySeparatorChar + Path.GetFileName(media.FilePath); if (File.Exists(finalFileName) && !YesToAll) { if (NoToAll) { continue; } string Prompt = String.Format( "{0}\nRe-target this media to the specified file? If the file content differs, this may destabilize your project. \n{1}", media.FilePath, finalFileName); var dlgRetarget = new YesNoAll(Prompt, "Re-target", "Leave"); DialogResult rsltRetarget = dlgRetarget.ShowDialog(); if (rsltRetarget == DialogResult.Yes) { if (dlgRetarget.ToAll) { YesToAll = true; } } else { if (dlgRetarget.ToAll) { NoToAll = true; } continue; } } progress.AddLog(String.Format("Copying {0} -> {1}...", media.FilePath, finalFileName)); progress.Refresh(); CopyOrRedirect(pool, media, finalFileName); progress.AddLog("...Done."); } progress.Close(); } PopulateMediaListItems(); }