Thanks,
as Geert said, there is no way to drop it directly on the form, but you must have open a diagram where you will try to drop your objects. It is not exactly what i wanted, but it works ...
You drag your object from the project browser to the diagram, and when you drop it, it will not drop on the diagram, but the name will appear in your ListBox (obviously, your add-in form must be activated and visible)...
here is how I did it:
1. first, I create the method:
public Boolean EA_OnPreDropFromTree( EA.Repository Repository, EA.EventProperties Info ) {
2. then, get the properties from Info:
// first property is: objectID
EA.EventProperty property = Info.Get( 0 );
string objectIdX = property.Value.Trim();
int objectId = Convert.ToInt32( objectIdX );
// second property is: objectType
property = Info.Get( 1 );
string objectTypeX = property.Value.Trim();
3. after this, get the objects, and add their names into ListBox:
switch ( objectTypeX )
{
case "4": // object type 4 = Element
EA.Element selectedElement = Repository.GetElementByID( objectId );
listBox1.Items.Add( selectedElement.Name );
break;
case "5": // object type 5 = Package
EA.Package selectedPackage = Repository.GetPackageByID( objectId );
listBox1.Items.Add( selectedPackage.Name );
break;
default:
break;
}
4. and on the end, return "false" in order to prevent dropping objects onto diagram:
return false;
full snippet:
public Boolean EA_OnPreDropFromTree( EA.Repository Repository, EA.EventProperties Info ) {
// first property is: objectID
EA.EventProperty property = Info.Get( 0 );
string objectIdX = property.Value.Trim();
int objectId = Convert.ToInt32( objectIdX );
// second property is: objectType
property = Info.Get( 1 );
string objectTypeX = property.Value.Trim();
switch ( objectTypeX )
{
case "4": // object type 4 = Element
EA.Element selectedElement = Repository.GetElementByID( objectId );
listBox1.Items.Add( selectedElement.Name );
break;
case "5": // object type 5 = Package
EA.Package selectedPackage = Repository.GetPackageByID( objectId );
listBox1.Items.Add( selectedPackage.Name );
break;
default:
break;
}
return false;
}
ljk