09-05-2008, 13:27
|
jigar

Joined on 08-22-2007
Posts 453
|
Re: Loading only Wang supported annotations in the toolbar
|
 
 
|
|
|
I'll answer your second question first. You cannot create the toolbar first and then add the buttons. You have to add them before calling CreateToolbar(). If you don't want to remove the buttons then you can create just the buttons you want manually, and in this case you should not call CreateDefaultObjects().
Now the reason why it's not removing some of the objects is because it keeps on incrementing the idx value when an object is removed. To give a small example, lets say you have a list, and you have 3 objects inside: A, B, and C. The Count value for the list is 3. Let's say you want to remove B and C from the list. If you remove the item at index 1, then you are left with A, C. Since you removed an item you don't want to increment the position to the next element because the list has gotten shorter (Count = 2).
So change your for loop to this:
for (int idx = 0; idx < annMgr.Objects.Count; /* see code in else statment below */ ) { annAutoObj = annMgr.Objects[idx]; if ((annAutoObj.Id == AnnAutomationManager.RulerObjectId) || (annAutoObj.Id == AnnAutomationManager.PolyRulerObjectId) || (annAutoObj.Id == AnnAutomationManager.ProtractorObjectId) || (annAutoObj.Id == AnnAutomationManager.StampObjectId) || (annAutoObj.Id == AnnAutomationManager.AudioObjectId) || (annAutoObj.Id == AnnAutomationManager.ButtonObjectId) || (annAutoObj.Id == AnnAutomationManager.CrossProductObjectId) || (annAutoObj.Id == AnnAutomationManager.HotspotObjectId) || (annAutoObj.Id == AnnAutomationManager.FreehandHotspotObjectId) || (annAutoObj.Id == AnnAutomationManager.PointObjectId) || (annAutoObj.Id == AnnAutomationManager.RubberStampObjectId) ) { annMgr.Objects.Remove(annAutoObj); } else { // Only increment if we DON'T remove an object. idx++; } } |
|
LEADTOOLS Technical Support
|
|
|
|
|
Report
|
|
|
|