In a SystemWeaver extension, you can listen for events. Below is a small example in an extension.


With the line shown below, a listener is added for the Item_AddPart event: 


_eventManager.Item_AddPart += AddPartEvent;


 It will listen for AddPart events for items the client has in its cache.


Example

In the below example, a message is shown if a part is added:

    [Plugin, VisualPlugin, NeedsManagedWrapper(typeof(WPFPluginContentWrapper))]
    public partial class ItemViewWithEventsContent : RemObjects.Hydra.WPF.VisualPlugin, IswItemViewContent
    {
        private IswItemViewHost _host;
        private SWEventManager _eventManager;
        private IswDialogs _dialogs;
        private IswItem _currentItem;

        public ItemViewWithEventsContent()
        {
            InitializeComponent();
            _eventManager = new SWEventManager();
        }

        public void SetHost(IswItemViewHost host)
        {
            _host = host;
            _host.SetEvent(_eventManager);
            _dialogs = _host.GetDialogs();
            _eventManager.Item_AddPart += AddPartEvent;
        }

        private void AddPartEvent(IswPart arg1, IswNodes arg2)
        {
            MessageBox.Show($"Part {arg1.Name} was added!");
        }

        public void SetCurrentItem(IswItem AItem)
        {
            _currentItem = AItem;
        }
    }