///**********************************************************************
/// Program: SplitEventAtCursor.cs
/// Author: John Rofrano
/// Description: This script will split the selected event at the
/// current cursor position.
/// Last Updated: December 20, 2012
/// Copyright: (c) 2012 Sundance Media Group, All Rights Reserved
///**********************************************************************
using System;
using System.Windows.Forms;
using Sony.Vegas;
class EntryPoint
{
///
/// Vegas entry point
///
///
public void FromVegas(Vegas vegas)
{
try
{
TrackEvent selectedEvent = GetSelectedEvent(vegas);
if (selectedEvent != null)
{
// make sure that the cursor is within the event boundaries
if (vegas.Transport.CursorPosition > selectedEvent.Start && vegas.Transport.CursorPosition < selectedEvent.End)
{
selectedEvent.Split(vegas.Transport.CursorPosition - selectedEvent.Start);
}
else
{
throw new ApplicationException("Cursor is not within the selected event.");
}
}
else
{
throw new ApplicationException("No event selected.");
}
}
catch (Exception e)
{
MessageBox.Show(e.Message, "Split At Cursor", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
///
/// Returns the first selected event
///
///
///
TrackEvent GetSelectedEvent(Vegas vegas)
{
foreach (Track track in vegas.Project.Tracks)
{
foreach (TrackEvent trackEvent in track.Events)
{
if (trackEvent.Selected)
{
return trackEvent;
}
}
}
return null;
}
}