public static PromptSelectionResult GetSelection(this Editor ed, PromptSelectionOptions options, AllowedClassFilter classFilter)
{
return ed.GetSelection((PromptSelectionOptions)null, classFilter);
}
/// <summary>
/// Gets the selection.
/// </summary>
/// <param name="ed">The ed.</param>
/// <param name="filter">The filter.</param>
/// <param name="classFilter">The class filter.</param>
/// <returns></returns>
public static PromptSelectionResult GetSelection(this Editor ed, SelectionFilter filter, AllowedClassFilter classFilter)
{
return ed.GetSelection((SelectionFilter)null, classFilter);
}
/// <summary>
/// Gets the selection.
/// </summary>
/// <param name="ed">The ed.</param>
/// <param name="classFilter">The class filter.</param>
/// <returns></returns>
public static PromptSelectionResult GetSelection(this Editor ed, AllowedClassFilter classFilter)
{
return ed.GetSelection((PromptSelectionOptions)null, (SelectionFilter)null, classFilter);
}
/// <summary>
/// Gets the selection.
/// </summary>
/// <param name="ed">The ed.</param>
/// <param name="options">The options.</param>
/// <param name="filter">The filter.</param>
/// <param name="classFilter">The class filter.</param>
/// <returns></returns>
public static PromptSelectionResult GetSelection(this Editor ed, PromptSelectionOptions options, SelectionFilter filter, AllowedClassFilter classFilter)
{
AllowedClassPtrs = classFilter.AllowedClassPtrs;
ed
.SelectionAdded += new SelectionAddedEventHandler
(ed_ClassFilterSelectionAdded
);
try
{
if (options != null)
{
if (filter != null)
{
return ed.GetSelection(options, filter);
}
else
{
return ed.GetSelection(options);
}
}
else if (filter != null)
{
return ed.GetSelection(filter);
}
else
{
return ed.GetSelection();
}
}
finally
{
ed
.SelectionAdded -= new SelectionAddedEventHandler
(ed_ClassFilterSelectionAdded
); }
}
/// <summary>
/// The allowed class PTRS
/// </summary>
private static ICollection<IntPtr> AllowedClassPtrs;
/// <summary>
/// Handles the ClassFilterSelectionAdded event of the ed control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="SelectionAddedEventArgs"/> instance containing the event data.</param>
private static void ed_ClassFilterSelectionAdded(object sender, SelectionAddedEventArgs e)
{
ObjectId[] ids = e.AddedObjects.GetObjectIds();
for (int i = 0; i < ids.Length; i++)
{
if (!AllowedClassPtrs.Contains(ids[i].ObjectClass.UnmanagedObject))
e.Remove(i);
}
}