fork download
  1. // Add Fade to selected Events.cs
  2. // 選択したイベントにフェードを設定するスクリプト(Vegas Pro用)
  3. //
  4. // - 準備
  5. // 1.上の[download]からファイルを保存
  6. // 2.[Add Fade to selected Events.cs]に名前変更
  7. // 3.Vegas Proインストールフォルダ内の[Script Menu]フォルダ※に移動
  8. // ※C:\Program Files\Sony\Vegas Pro {version}\Script Menu\
  9. //
  10. // - 使い方
  11. // 1.フェード時間を変更したいイベントを選択(複数可)
  12. // 2.[ツール]->[スクリプトの作成]->[Add Fade to selected Events]をクリック
  13. // 3.フェード時間を設定(単位:ミリ秒 ※1秒=1000ミリ秒)
  14. // 4.OKをクリック(Enterでも可)
  15. //
  16. // - 備考
  17. // ・0msに設定するとフェード解除になります。
  18. // ・チェックボックスでフェード イン/アウトの個別設定できます。
  19. // ・ツールバーの変更[オプション]->[ツールバーのカスタマイズ]を開いて
  20. // [利用できるツール バー ボタン]の中の[Add Fade to selected Events]を選択し
  21. // [追加]しておくと、ツールバーから実行できて便利です。
  22. //
  23. // 公開場所 http://i...content-available-to-author-only...e.com/1GtbDF
  24. // 姉妹品(削除専用) http://i...content-available-to-author-only...e.com/4uvWR1
  25. using System;
  26. using System.Drawing;
  27. using System.Windows.Forms;
  28. using System.Collections.Generic;
  29. using Sony.Vegas;
  30.  
  31. class EntryPoint
  32. {
  33. public void FromVegas(Vegas vegas)
  34. {
  35. FadeDialog dialog = new FadeDialog();
  36. DialogResult result = dialog.ShowDialog();
  37.  
  38. if (result == DialogResult.Cancel ||
  39. !dialog.FadeInEnabled || !dialog.FadeOutEnabled)
  40. return;
  41.  
  42. IEnumerable<TrackEvent> events = FindSelectedEvents(vegas);
  43. foreach (TrackEvent item in events)
  44. {
  45. if (dialog.FadeInEnabled)
  46. item.FadeIn.Length = dialog.FadeInOffset;
  47.  
  48. if (dialog.FadeOutEnabled)
  49. item.FadeOut.Length = dialog.FadeOutOffset;
  50. }
  51. }
  52.  
  53. IEnumerable<TrackEvent> FindSelectedEvents(Vegas vegas)
  54. {
  55. foreach (Track track in vegas.Project.Tracks)
  56. {
  57. foreach (TrackEvent evnt in track.Events)
  58. {
  59. if (evnt.Selected)
  60. {
  61. yield return evnt;
  62. }
  63. }
  64. }
  65. yield break;
  66. }
  67. }
  68.  
  69. partial class FadeDialog : Form
  70. {
  71. public bool FadeInEnabled { get { return inCheckBox.Enabled; } }
  72. public bool FadeOutEnabled { get { return outCheckBox.Enabled; } }
  73. public Timecode FadeInOffset { get { return new Timecode((double)inNumericUpDown.Value); } }
  74. public Timecode FadeOutOffset { get { return new Timecode((double)outNumericUpDown.Value); } }
  75.  
  76. public FadeDialog()
  77. {
  78. InitializeComponent();
  79. }
  80. }
  81.  
  82. // UI実装
  83. partial class FadeDialog
  84. {
  85. /// <summary>
  86. /// Required designer variable.
  87. /// </summary>
  88. private System.ComponentModel.IContainer components = null;
  89.  
  90. /// <summary>
  91. /// Clean up any resources being used.
  92. /// </summary>
  93. /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
  94. protected override void Dispose(bool disposing)
  95. {
  96. if (disposing && (components != null))
  97. {
  98. components.Dispose();
  99. }
  100. base.Dispose(disposing);
  101. }
  102.  
  103. #region Windows Form Designer generated code
  104.  
  105. /// <summary>
  106. /// Required method for Designer support - do not modify
  107. /// the contents of this method with the code editor.
  108. /// </summary>
  109. private void InitializeComponent()
  110. {
  111. this.inNumericUpDown = new System.Windows.Forms.NumericUpDown();
  112. this.outNumericUpDown = new System.Windows.Forms.NumericUpDown();
  113. this.inCheckBox = new System.Windows.Forms.CheckBox();
  114. this.outCheckBox = new System.Windows.Forms.CheckBox();
  115. this.okButton = new System.Windows.Forms.Button();
  116. this.cancelButton = new System.Windows.Forms.Button();
  117. ((System.ComponentModel.ISupportInitialize)(this.inNumericUpDown)).BeginInit();
  118. ((System.ComponentModel.ISupportInitialize)(this.outNumericUpDown)).BeginInit();
  119. this.SuspendLayout();
  120. //
  121. // inNumericUpDown
  122. //
  123. this.inNumericUpDown.Increment = new decimal(new int[] {
  124. 100,
  125. 0,
  126. 0,
  127. 0});
  128. this.inNumericUpDown.Location = new System.Drawing.Point(87, 7);
  129. this.inNumericUpDown.Maximum = new decimal(new int[] {
  130. 100000,
  131. 0,
  132. 0,
  133. 0});
  134. this.inNumericUpDown.Name = "inNumericUpDown";
  135. this.inNumericUpDown.Size = new System.Drawing.Size(75, 19);
  136. this.inNumericUpDown.TabIndex = 2;
  137. this.inNumericUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
  138. this.inNumericUpDown.ThousandsSeparator = true;
  139. this.inNumericUpDown.Value = new decimal(new int[] {
  140. 500,
  141. 0,
  142. 0,
  143. 0});
  144. //
  145. // outNumericUpDown
  146. //
  147. this.outNumericUpDown.Increment = new decimal(new int[] {
  148. 100,
  149. 0,
  150. 0,
  151. 0});
  152. this.outNumericUpDown.Location = new System.Drawing.Point(87, 32);
  153. this.outNumericUpDown.Maximum = new decimal(new int[] {
  154. 100000,
  155. 0,
  156. 0,
  157. 0});
  158. this.outNumericUpDown.Name = "outNumericUpDown";
  159. this.outNumericUpDown.Size = new System.Drawing.Size(75, 19);
  160. this.outNumericUpDown.TabIndex = 4;
  161. this.outNumericUpDown.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
  162. this.outNumericUpDown.ThousandsSeparator = true;
  163. this.outNumericUpDown.Value = new decimal(new int[] {
  164. 500,
  165. 0,
  166. 0,
  167. 0});
  168. //
  169. // inCheckBox
  170. //
  171. this.inCheckBox.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
  172. this.inCheckBox.Checked = true;
  173. this.inCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
  174. this.inCheckBox.Location = new System.Drawing.Point(12, 8);
  175. this.inCheckBox.Name = "inCheckBox";
  176. this.inCheckBox.Size = new System.Drawing.Size(70, 16);
  177. this.inCheckBox.TabIndex = 1;
  178. this.inCheckBox.Text = "FadeIn";
  179. this.inCheckBox.UseVisualStyleBackColor = true;
  180. //
  181. // outCheckBox
  182. //
  183. this.outCheckBox.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
  184. this.outCheckBox.Checked = true;
  185. this.outCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
  186. this.outCheckBox.Location = new System.Drawing.Point(12, 33);
  187. this.outCheckBox.Name = "outCheckBox";
  188. this.outCheckBox.Size = new System.Drawing.Size(70, 16);
  189. this.outCheckBox.TabIndex = 3;
  190. this.outCheckBox.Text = "FadeOut";
  191. this.outCheckBox.UseVisualStyleBackColor = true;
  192. //
  193. // okButton
  194. //
  195. this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
  196. this.okButton.Location = new System.Drawing.Point(12, 57);
  197. this.okButton.Name = "okButton";
  198. this.okButton.Size = new System.Drawing.Size(75, 23);
  199. this.okButton.TabIndex = 5;
  200. this.okButton.Text = "OK";
  201. this.okButton.UseVisualStyleBackColor = true;
  202. //
  203. // cancelButton
  204. //
  205. this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
  206. this.cancelButton.Location = new System.Drawing.Point(87, 57);
  207. this.cancelButton.Name = "cancelButton";
  208. this.cancelButton.Size = new System.Drawing.Size(75, 23);
  209. this.cancelButton.TabIndex = 6;
  210. this.cancelButton.Text = "Cancel";
  211. this.cancelButton.UseVisualStyleBackColor = true;
  212. //
  213. // FadeDialog
  214. //
  215. this.AcceptButton = this.okButton;
  216. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  217. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  218. this.CancelButton = this.cancelButton;
  219. this.ClientSize = new System.Drawing.Size(174, 86);
  220. this.Controls.Add(this.cancelButton);
  221. this.Controls.Add(this.okButton);
  222. this.Controls.Add(this.outCheckBox);
  223. this.Controls.Add(this.inCheckBox);
  224. this.Controls.Add(this.outNumericUpDown);
  225. this.Controls.Add(this.inNumericUpDown);
  226. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
  227. this.MaximizeBox = false;
  228. this.MinimizeBox = false;
  229. this.Name = "FadeDialog";
  230. this.ShowInTaskbar = false;
  231. this.Text = "フェード設定";
  232. ((System.ComponentModel.ISupportInitialize)(this.inNumericUpDown)).EndInit();
  233. ((System.ComponentModel.ISupportInitialize)(this.outNumericUpDown)).EndInit();
  234. this.ResumeLayout(false);
  235.  
  236. inCheckBox.CheckedChanged += inCheckBox_CheckedChanged;
  237. outCheckBox.CheckedChanged += outCheckBox_CheckedChanged;
  238. }
  239.  
  240. void inCheckBox_CheckedChanged(object sender, EventArgs e)
  241. {
  242. inNumericUpDown.Enabled = ((CheckBox)sender).Checked;
  243. }
  244.  
  245. void outCheckBox_CheckedChanged(object sender, EventArgs e)
  246. {
  247. outNumericUpDown.Enabled = ((CheckBox)sender).Checked;
  248. }
  249.  
  250. #endregion
  251.  
  252. private System.Windows.Forms.NumericUpDown inNumericUpDown;
  253. private System.Windows.Forms.NumericUpDown outNumericUpDown;
  254. private System.Windows.Forms.CheckBox inCheckBox;
  255. private System.Windows.Forms.CheckBox outCheckBox;
  256. private System.Windows.Forms.Button okButton;
  257. private System.Windows.Forms.Button cancelButton;
  258. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(27,14): error CS0234: The type or namespace name `Windows' does not exist in the namespace `System'. Are you missing an assembly reference?
prog.cs(29,7): error CS0246: The type or namespace name `Sony' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(33,27): error CS0246: The type or namespace name `Vegas' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(53,17): error CS0246: The type or namespace name `TrackEvent' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(252,20): error CS0234: The type or namespace name `Windows' does not exist in the namespace `System'. Are you missing an assembly reference?
prog.cs(253,20): error CS0234: The type or namespace name `Windows' does not exist in the namespace `System'. Are you missing an assembly reference?
prog.cs(254,20): error CS0234: The type or namespace name `Windows' does not exist in the namespace `System'. Are you missing an assembly reference?
prog.cs(255,20): error CS0234: The type or namespace name `Windows' does not exist in the namespace `System'. Are you missing an assembly reference?
prog.cs(256,20): error CS0234: The type or namespace name `Windows' does not exist in the namespace `System'. Are you missing an assembly reference?
prog.cs(257,20): error CS0234: The type or namespace name `Windows' does not exist in the namespace `System'. Are you missing an assembly reference?
prog.cs(73,12): error CS0246: The type or namespace name `Timecode' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(74,12): error CS0246: The type or namespace name `Timecode' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(94,29): error CS0115: `FadeDialog.Dispose(bool)' is marked as an override but no suitable method found to override
Compilation failed: 13 error(s), 0 warnings
stdout
Standard output is empty