using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Windows.Forms;
using Microsoft.VisualStudio.SourceSafe.Interop;
namespace IvssEventSample
{
// Use attributes to declare a fixed Prog ID and Guid for the Add-In.
[ProgId("Microsoft.SourceSafe.EventSample")]
[Guid("E1916BD8-A8AA-47b7-A862-C1AF995E64EF")]
[ComVisible(true)]
public class IvssEventSample : IVSSEventHandler, IVSSEvents
{
private VSSApp vssApp;
IConnectionPoint vssEvents;
int cookie;
public IvssEventSample()
{
}
~IvssEventSample()
{}
public void Init(VSSApp app)
{
MessageBox.Show("Init");
// by saving the VSSApp pointer you can drive the database during events
this.vssApp = app;
// Wire up the COM connection point manually
IConnectionPointContainer cpc = (IConnectionPointContainer) app;
Guid guid = typeof(IVSSEvents).GUID;
cpc.FindConnectionPoint(ref guid, out vssEvents);
vssEvents.Advise(this, out cookie);
}
public void AfterAdd(VSSItem vssItem, string localSpec, string comment)
{
MessageBox.Show("AfterAdd");
}
public void AfterBranch(VSSItem vssItem, string comment)
{
MessageBox.Show("AfterBranch");
}
public void AfterCheckin(VSSItem vssItem, string localSpec, string comment)
{
MessageBox.Show("AfterCheckin");
}
public void AfterCheckout(VSSItem vssItem, string localSpec, string comment)
{
MessageBox.Show("AfterCheckout");
}
public void AfterEvent(int eventNum, VSSItem vssItem, string str, object var)
{
// Use of this event is deprecated
}
public void AfterRename(VSSItem vssItem, string oldName)
{
MessageBox.Show("AfterRename");
}
public void AfterUndoCheckout(VSSItem vssItem, string localSpec)
{
MessageBox.Show("AfterUndoCheckout");
}
public bool BeforeAdd(VSSItem vssItem, string localSpec, string comment)
{
MessageBox.Show("BeforeAdd");
return true;
}
public bool BeforeBranch(VSSItem vssItem, string comment)
{
MessageBox.Show("BeforeBranch");
return true;
}
public bool BeforeCheckin(VSSItem vssItem, string localSpec, string comment)
{
MessageBox.Show("BeforeCheckin");
return true;
}
public bool BeforeCheckout(VSSItem vssItem, string localSpec, string comment)
{
MessageBox.Show("BeforeCheckout");
return true;
}
public bool BeforeEvent(int eventNum, VSSItem vssItem, string str, object var)
{
// Use of this event is deprecated
return true;
}
public bool BeforeRename(VSSItem vssItem, string oldName)
{
MessageBox.Show("BeforeRename");
return true;
}
public bool BeforeUndoCheckout(VSSItem vssItem, string localSpec)
{
MessageBox.Show("BeforeUndoCheckout");
return true;
}
public bool BeginCommand(int unused)
{
// use of this event is deprecated
return true;
}
public void EndCommand(int unused)
{
// Use of this event is deprecated
}
}
}