// Add Fade to selected Events.cs
// 選択したイベントにフェードを設定するスクリプト(Vegas Pro用)
//
// - 準備
// 1.上の[download]からファイルを保存
// 2.[Add Fade to selected Events.cs]に名前変更
// 3.Vegas Proインストールフォルダ内の[Script Menu]フォルダ※に移動
// ※C:\Program Files\Sony\Vegas Pro {version}\Script Menu\
//
// - 使い方
// 1.フェード時間を変更したいイベントを選択(複数可)
// 2.[ツール]->[スクリプトの作成]->[Add Fade to selected Events]をクリック
// 3.フェード時間を設定(単位:ミリ秒 ※1秒=1000ミリ秒)
// 4.OKをクリック(Enterでも可)
//
// - 備考
// ・0msに設定するとフェード解除になります。
// ・チェックボックスでフェード イン/アウトの個別設定できます。
// ・ツールバーの変更[オプション]->[ツールバーのカスタマイズ]を開いて
// [利用できるツール バー ボタン]の中の[Add Fade to selected Events]を選択し
// [追加]しておくと、ツールバーから実行できて便利です。
//
// 公開場所 http://i...content-available-to-author-only...e.com/1GtbDF
// 姉妹品(削除専用) http://i...content-available-to-author-only...e.com/4uvWR1
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using Sony.Vegas;
class EntryPoint
{
public void FromVegas(Vegas vegas)
{
FadeDialog dialog = new FadeDialog();
DialogResult result = dialog.ShowDialog();
if (result == DialogResult.Cancel ||
!dialog.FadeInEnabled || !dialog.FadeOutEnabled)
return;
IEnumerable<TrackEvent> events = FindSelectedEvents(vegas);
foreach (TrackEvent item in events)
{
if (dialog.FadeInEnabled)
item.FadeIn.Length = dialog.FadeInOffset;
if (dialog.FadeOutEnabled)
item.FadeOut.Length = dialog.FadeOutOffset;
}
}
IEnumerable<TrackEvent> FindSelectedEvents(Vegas vegas)
{
foreach (Track track in vegas.Project.Tracks)
{
foreach (TrackEvent evnt in track.Events)
{
if (evnt.Selected)
{
yield return evnt;
}
}
}
yield break;
}
}
partial class FadeDialog : Form
{
public bool FadeInEnabled { get { return inCheckBox.Enabled; } }
public bool FadeOutEnabled { get { return outCheckBox.Enabled; } }
public Timecode FadeInOffset { get { return new Timecode((double)inNumericUpDown.Value); } }
public Timecode FadeOutOffset { get { return new Timecode((double)outNumericUpDown.Value); } }
public FadeDialog()
{
InitializeComponent();
}
}
// UI実装
partial class FadeDialog
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.inNumericUpDown = new System.Windows.Forms.NumericUpDown();
this.outNumericUpDown = new System.Windows.Forms.NumericUpDown();
this.inCheckBox = new System.Windows.Forms.CheckBox();
this.outCheckBox = new System.Windows.Forms.CheckBox();
this.okButton = new System.Windows.Forms.Button();
this.cancelButton = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.inNumericUpDown)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.outNumericUpDown)).BeginInit();
this.SuspendLayout();
//
// inNumericUpDown
//
this.inNumericUpDown.Increment = new decimal(new int[] {
100,
0,
0,
0});
this.inNumericUpDown.Location = new System.Drawing.Point(87, 7);
this.inNumericUpDown.Maximum = new decimal(new int[] {
100000,
0,
0,
0});
this.inNumericUpDown.Name = "inNumericUpDown";
this.inNumericUpDown.Size = new System.Drawing.Size(75, 19);
this.inNumericUpDown.TabIndex = 2;
this.inNumericUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.inNumericUpDown.ThousandsSeparator = true;
this.inNumericUpDown.Value = new decimal(new int[] {
500,
0,
0,
0});
//
// outNumericUpDown
//
this.outNumericUpDown.Increment = new decimal(new int[] {
100,
0,
0,
0});
this.outNumericUpDown.Location = new System.Drawing.Point(87, 32);
this.outNumericUpDown.Maximum = new decimal(new int[] {
100000,
0,
0,
0});
this.outNumericUpDown.Name = "outNumericUpDown";
this.outNumericUpDown.Size = new System.Drawing.Size(75, 19);
this.outNumericUpDown.TabIndex = 4;
this.outNumericUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.outNumericUpDown.ThousandsSeparator = true;
this.outNumericUpDown.Value = new decimal(new int[] {
500,
0,
0,
0});
//
// inCheckBox
//
this.inCheckBox.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
this.inCheckBox.Checked = true;
this.inCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
this.inCheckBox.Location = new System.Drawing.Point(12, 8);
this.inCheckBox.Name = "inCheckBox";
this.inCheckBox.Size = new System.Drawing.Size(70, 16);
this.inCheckBox.TabIndex = 1;
this.inCheckBox.Text = "FadeIn";
this.inCheckBox.UseVisualStyleBackColor = true;
//
// outCheckBox
//
this.outCheckBox.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
this.outCheckBox.Checked = true;
this.outCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
this.outCheckBox.Location = new System.Drawing.Point(12, 33);
this.outCheckBox.Name = "outCheckBox";
this.outCheckBox.Size = new System.Drawing.Size(70, 16);
this.outCheckBox.TabIndex = 3;
this.outCheckBox.Text = "FadeOut";
this.outCheckBox.UseVisualStyleBackColor = true;
//
// okButton
//
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
this.okButton.Location = new System.Drawing.Point(12, 57);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(75, 23);
this.okButton.TabIndex = 5;
this.okButton.Text = "OK";
this.okButton.UseVisualStyleBackColor = true;
//
// cancelButton
//
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancelButton.Location = new System.Drawing.Point(87, 57);
this.cancelButton.Name = "cancelButton";
this.cancelButton.Size = new System.Drawing.Size(75, 23);
this.cancelButton.TabIndex = 6;
this.cancelButton.Text = "Cancel";
this.cancelButton.UseVisualStyleBackColor = true;
//
// FadeDialog
//
this.AcceptButton = this.okButton;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.cancelButton;
this.ClientSize = new System.Drawing.Size(174, 86);
this.Controls.Add(this.cancelButton);
this.Controls.Add(this.okButton);
this.Controls.Add(this.outCheckBox);
this.Controls.Add(this.inCheckBox);
this.Controls.Add(this.outNumericUpDown);
this.Controls.Add(this.inNumericUpDown);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FadeDialog";
this.ShowInTaskbar = false;
this.Text = "フェード設定";
((System.ComponentModel.ISupportInitialize)(this.inNumericUpDown)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.outNumericUpDown)).EndInit();
this.ResumeLayout(false);
inCheckBox.CheckedChanged += inCheckBox_CheckedChanged;
outCheckBox.CheckedChanged += outCheckBox_CheckedChanged;
}
void inCheckBox_CheckedChanged(object sender, EventArgs e)
{
inNumericUpDown.Enabled = ((CheckBox)sender).Checked;
}
void outCheckBox_CheckedChanged(object sender, EventArgs e)
{
outNumericUpDown.Enabled = ((CheckBox)sender).Checked;
}
#endregion
private System.Windows.Forms.NumericUpDown inNumericUpDown;
private System.Windows.Forms.NumericUpDown outNumericUpDown;
private System.Windows.Forms.CheckBox inCheckBox;
private System.Windows.Forms.CheckBox outCheckBox;
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.Button cancelButton;
}