Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - keithbrown

Pages: [1]
1
Events / Re: EventHandler for Entity Selection
« on: February 26, 2014, 01:34:12 PM »
This is an older thread but i thought i would post anyway in case anyone heading this way wanted a solution.  As BlackBox said the event that you want is the ImpliedSelectionChanged event.  In the code snippet below I am checking the implied selection to see if a single object is selected.

Code: [Select]
       private void DocumentManager_ImpliedSelectionChanged(object sender, EventArgs e)
        {
            Document document = Application.DocumentManager.MdiActiveDocument;
            PromptSelectionResult promptSelectionResult = document.Editor.SelectImplied();

            // If no objects are selected then do something and return
            if (promptSelectionResult.Value == null)
            {
                // Do Something
                return;
            }

            // If more than one object is selected then do something
            if (promptSelectionResult.Value.Count > 1)
            {
                // Do Something
                return;
            }

            // At this point only one object should be selected.
            // Do Something             

 
            }

And below is the code that i would use to initiate the event handler

Code: [Select]
var document = Application.DocumentManager.MdiActiveDocument;
document.ImpliedSelectionChanged += DocumentManager_ImpliedSelectionChanged;

I just make sure to setup the event handler in each document as it is created and remove it as each document is destroyed.

Pages: [1]