SelectionCombinationMethod Enumeration
In This Topic
Define combination methods for selection operations. They determine how
the selection performed will combine with an existing selection.
Syntax
Members
Member | Description |
Add |
Adds to the current selection.
|
And |
Selects from the current selection.
|
New |
Creates a new selection.
|
Subtract |
Subtracts from the current selection.
|
XOR |
Performs an 'exclusive or' with the current selection.
|
Example
Spatial selection of elements in all Graphics Layers
//Map Tool is used to perform Spatial selection.
//Graphic selection uses the selection geometry
//to intersect the geometries of those elements (graphic or group)
//that will be selected and then highlights them.
protected override async Task<bool> OnSketchCompleteAsync(Geometry geometry)
{
var selPoly = geometry as Polygon;
return await QueuedTask.Run(() =>
{
//note: the selected elements may belong to more than one layer...
var elems = MapView.Active.SelectElements(selPoly, SelectionCombinationMethod.New);
return true;
});
}
Spatial selection of elements in one graphics layer
//on the QueuedTask
//Create an extent to use for the spatial selection
var extent = MapView.Active.Extent;
var selectionExtent = extent.Expand(0.5, 0.5, true);
//Select elements in specified graphics layer using the selection extent.
var selectedElements = MapView.Active.SelectElements(graphicsLayer, selectionExtent, SelectionCombinationMethod.Add);
Select Text Graphic Elements
var graphicsLayer = MapView.Active.Map.GetLayersAsFlattenedList()
.OfType<ArcGIS.Desktop.Mapping.GraphicsLayer>().FirstOrDefault();
if (graphicsLayer == null)
return;
var all_text = graphicsLayer.GetElementsAsFlattenedList()
.Where(e => e.GetGraphic() is CIMTextGraphic);
Get/Set Selection Options
var options = ApplicationOptions.SelectionOptions;
QueuedTask.Run(() =>
{
var defaultColor = options.DefaultSelectionColor;
var color = options.SelectionColor as CIMRGBColor;
options.SetSelectionColor(ColorFactory.Instance.CreateRGBColor(255, 0, 0));
var defaultFill = options.DefaultSelectionFillColor;
var fill = options.SelectionFillColor;
var isHatched = options.IsSelectionFillHatched;
options.SetSelectionFillColor(ColorFactory.Instance.CreateRGBColor(100, 100, 0));
if (!isHatched)
options.SetSelectionFillIsHatched(true);
var showSelectionChip = options.ShowSelectionChip;
options.SetShowSelectionChip(!showSelectionChip);
var showSelectionGraphic = options.ShowSelectionGraphic;
options.SetShowSelectionGraphic(!showSelectionGraphic);
var saveSelection = options.SaveSelection;
options.SetSaveSelection(!saveSelection);
var defaultTol = options.DefaultSelectionTolerance;
var tol = options.SelectionTolerance;
options.SetSelectionTolerance(2 * defaultTol);
// extension methods available
var selMethod = options.SelectionMethod;
options.SetSelectionMethod(SelectionMethod.Contains);
var combMethod = options.CombinationMethod;
options.SetCombinationMethod(SelectionCombinationMethod.Add);
// note that the following SelectionCombinationMethod is not supported
//options.SetCombinationMethod(SelectionCombinationMethod.XOR);
});
Get/Set Selection Options
var options = ApplicationOptions.SelectionOptions;
QueuedTask.Run(() =>
{
var defaultColor = options.DefaultSelectionColor;
var color = options.SelectionColor as CIMRGBColor;
options.SetSelectionColor(ColorFactory.Instance.CreateRGBColor(255, 0, 0));
var defaultFill = options.DefaultSelectionFillColor;
var fill = options.SelectionFillColor;
var isHatched = options.IsSelectionFillHatched;
options.SetSelectionFillColor(ColorFactory.Instance.CreateRGBColor(100, 100, 0));
if (!isHatched)
options.SetSelectionFillIsHatched(true);
var showSelectionChip = options.ShowSelectionChip;
options.SetShowSelectionChip(!showSelectionChip);
var showSelectionGraphic = options.ShowSelectionGraphic;
options.SetShowSelectionGraphic(!showSelectionGraphic);
var saveSelection = options.SaveSelection;
options.SetSaveSelection(!saveSelection);
var defaultTol = options.DefaultSelectionTolerance;
var tol = options.SelectionTolerance;
options.SetSelectionTolerance(2 * defaultTol);
// extension methods available
var selMethod = options.SelectionMethod;
options.SetSelectionMethod(SelectionMethod.Contains);
var combMethod = options.CombinationMethod;
options.SetCombinationMethod(SelectionCombinationMethod.Add);
// note that the following SelectionCombinationMethod is not supported
//options.SetCombinationMethod(SelectionCombinationMethod.XOR);
});
Inheritance Hierarchy
System.Object
System.ValueType
System.Enum
ArcGIS.Desktop.Mapping.SelectionCombinationMethod
Requirements
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.
See Also