Anonymous
in reply to:
Anonymous
11-27-2016
01:32 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
11-27-2016
01:32 PM
İrfan Şahin dostum;
Did you translate Mr. Jef's VB codes to C#?
I just need handling of OnDocumentActive, but not as addin; I'm trying to make an executable application. May you help me?
Thanks in advance to everybody.
using System;
using Inventor;
namespace WpfInventor45
{
public interface IApplicationEventsLib
{
ApplicationEvents ApplicationEvents { get; }
ApplicationEventsSink_OnActivateDocumentEventHandler OnActivateDocumentDelegate
{
get;
set;
}
void Deactivate();
void I_Need_This(Inventor._Document DocumentObject, Inventor.EventTimingEnum BeforeOrAfter, Inventor.NameValueMap Context, ref Inventor.HandlingCodeEnum HandlingCode);
}
public class ApplicationEventsLib : IApplicationEventsLib
{
private readonly Application inventorApp;
public ApplicationEventsLib(Application inventorApp)
{
this.inventorApp = inventorApp;
ApplicationEvents = this.inventorApp.ApplicationEvents;
Activate();
}
public ApplicationEventsSink_OnActivateDocumentEventHandler OnActivateDocumentDelegate
{
get; set;
}
public ApplicationEvents ApplicationEvents { get; private set; }
public void I_Need_This(Inventor._Document DocumentObject, Inventor.EventTimingEnum BeforeOrAfter, Inventor.NameValueMap Context, ref Inventor.HandlingCodeEnum HandlingCode)
{
if ((BeforeOrAfter == Inventor.EventTimingEnum.kAfter))
Console.WriteLine("Code here!!");
}
private void Activate()
{
// I'm Getting error: No overload for .. matches delegate..
OnActivateDocumentDelegate = new ApplicationEventsSink_OnActivateDocumentEventHandler(I_Need_This);
ApplicationEvents.OnActivateDocument += OnActivateDocumentDelegate;
}
public void Deactivate()
{
ApplicationEvents.OnActivateDocument -= OnActivateDocumentDelegate;
OnActivateDocumentDelegate = null;
}
}
}