public class ElementEventArgs : System.EventArgs
Public Class ElementEventArgs Inherits System.EventArgs
public class ElementEventArgs : System.EventArgs
Public Class ElementEventArgs Inherits System.EventArgs
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 a map frame is activated or deactivated. //At 2.x - ArcGIS.Desktop.Layouts.Events.ActivateMapFrameEvent.Subscribe((args) => //{ // System.Windows.MessageBox.Show("ActiveMapFrameEvent:" + // Environment.NewLine + // " arg IsActivated: " + args.IsActivated.ToString() + // Environment.NewLine + // " arg Layout: " + args.Layout.Name + // Environment.NewLine + // " arg MapFrame: " + args.MapFrame.Name); //}); ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) => { var mapFrameName = args.Elements[0].Name; if (args.Hint == ElementEventHint.MapFrameActivated) { System.Diagnostics.Debug.WriteLine($"ElementEventHint.MapFrameActivated: {mapFrameName}"); } else if (args.Hint == ElementEventHint.MapFrameDeactivated) { System.Diagnostics.Debug.WriteLine($"ElementEventHint.MapFrameDeactivated: {mapFrameName}"); } });
//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}"); } });
//Report the event args when a layout's selection has changed. //At 2.x - ArcGIS.Desktop.Layouts.Events.LayoutSelectionChangedEvent.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("LayoutSelectionChangedEvent:" + // Environment.NewLine + // " arg Elements: " + elemNames.ToString() + // Environment.NewLine + // " arg Layout: " + args.Layout.Name); //}); ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) => { if (args.Hint == ElementEventHint.SelectionChanged) { if (args.Container.GetSelectedElements()?.Count() > 0) { var elemNames = string.Join(",", args.Container.GetSelectedElements().Select(e => e.Name).ToList()); System.Diagnostics.Debug.WriteLine($"ElementEventHint.SelectionChanged: {elemNames}"); } } });
//Report the event args when an element has been updated. //At 2.x - ArcGIS.Desktop.Layouts.Events.ElementsUpdatedEvent.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("ElementsUpdatedEvent:" + // Environment.NewLine + // " arg Elements: " + elemNames.ToString() + // Environment.NewLine + // " arg Layout: " + args.Layout.Name); //}); ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) => { string elemNames = "null"; //can be null if the name was changed if (args.Elements?.Count() > 0) { elemNames = string.Join(",", args.Elements.Select(e => e.Name).ToList()); } else if (args.Container.GetSelectedElements()?.Count() > 0) { elemNames = string.Join(",", args.Container.GetSelectedElements().Select(e => e.Name).ToList()); } if (args.Hint == ElementEventHint.PropertyChanged) { System.Diagnostics.Debug.WriteLine($"ElementEventHint.PropertyChanged: {elemNames}"); } });
System.Object
System.EventArgs
ArcGIS.Desktop.Layouts.Events.ElementEventArgs
Target Platforms: Windows 11, Windows 10