public IElement[] Elements {get;}
Public ReadOnly Property Elements As IElement()
public IElement[] Elements {get;}
Public ReadOnly Property Elements As IElement()
ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) => { //check if the container is a graphics layer - could be a Layout (or even map view) if (args.Container is ArcGIS.Desktop.Mapping.GraphicsLayer graphicsLayer) { //get the total selection count for the container var count = args.Elements.Count(); //Check count - could have been an unselect or clearselect if (count > 0) { //this is a selection or add to selection var elems = graphicsLayer.GetSelectedElements(); //TODO process the selection... } else { //This is an unselect or clear selection //TODO process the unselect or clear select } } });
//Report the event args when an element is added to the layout. //At 2.x - ArcGIS.Desktop.Layouts.Events.ElementAddedEvent.Subscribe((args) => //{ // var elements = args.Elements; // string elemNames = "null"; // if (elements != null && elements.Count() > 0) // { // elemNames = string.Join(",", elements.Select(e => e.Name).ToList()); // } // System.Windows.MessageBox.Show("ElementAddedEvent:" + // Environment.NewLine + // " arg Elements: " + elemNames.ToString() + // Environment.NewLine + // " arg Layout: " + args.Layout.Name); //}); ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) => { string elemNames = "null"; if (args.Elements?.Count() > 0) { elemNames = string.Join(",", args.Elements.Select(e => e.Name).ToList()); } if (args.Hint == ElementEventHint.ElementAdded) { System.Diagnostics.Debug.WriteLine($"ElementEventHint.ElementAdded: {elemNames}"); } });
//Report the event args when an element is removed from the layout. //At 2.x - ArcGIS.Desktop.Layouts.Events.ElementRemovedEvent.Subscribe((args) => //{ // var elements = args.Elements; // string elemNames = "null"; // if (elements != null && elements.Count() > 0) // { // elemNames = string.Join(",", elements.Select(e => e.Name).ToList()); // } // System.Windows.MessageBox.Show("ElementRemovedEvent:" + // Environment.NewLine + // " arg Elements: " + elemNames.ToString() + // Environment.NewLine + // " arg Layout: " + args.Layout.Name); //}); ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) => { string elemNames = "null"; if (args.Elements?.Count() > 0) { elemNames = string.Join(",", args.Elements.Select(e => e.Name).ToList()); } if (args.Hint == ElementEventHint.ElementRemoved) { System.Diagnostics.Debug.WriteLine($"ElementEventHint.ElementRemoved: {elemNames}"); } });
//Report the event args when an element's placement properties are changed. //At 2.x - ArcGIS.Desktop.Layouts.Events.ElementsPlacementChangedEvent.Subscribe((args) => //{ // var elements = args.Elements; // string elemNames = "null"; // if (elements != null && elements.Count() > 0) // { // elemNames = string.Join(",", elements.Select(e => e.Name).ToList()); // } // System.Windows.MessageBox.Show("ElementsPlacementChangedEvent:" + // Environment.NewLine + // " arg Elements: " + elemNames.ToString() + // Environment.NewLine + // " arg Layout: " + args.Layout.Name); //}); ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) => { string elemNames = "null"; if (args.Elements?.Count() > 0) { elemNames = string.Join(",", args.Elements.Select(e => e.Name).ToList()); } if (args.Hint == ElementEventHint.PlacementChanged) { System.Diagnostics.Debug.WriteLine($"ElementEventHint.PlacementChanged: {elemNames}"); } });
//Report the event args when an element's style is changed. //At 2.x - ArcGIS.Desktop.Layouts.Events.ElementStyleChangedEvent.Subscribe((args) => //{ // var elements = args.Elements; // string elemNames = "null"; // if (elements != null && elements.Count() > 0) // { // elemNames = string.Join(",", elements.Select(e => e.Name).ToList()); // } // System.Windows.MessageBox.Show("ElementStyleChangedEvent:" + // Environment.NewLine + // " arg Elements: " + elemNames.ToString() + // Environment.NewLine + // " arg Layout: " + args.Layout.Name); //}); ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) => { string elemNames = "null"; if (args.Elements?.Count() > 0) { elemNames = string.Join(",", args.Elements.Select(e => e.Name).ToList()); } if (args.Hint == ElementEventHint.StyleChanged) { System.Diagnostics.Debug.WriteLine($"ElementEventHint.StyleChanged: {elemNames}"); } });
Target Platforms: Windows 11, Windows 10, Windows 8.1