public class ProjectItemsChangedEventArgs : System.EventArgs
Public Class ProjectItemsChangedEventArgs Inherits System.EventArgs
public class ProjectItemsChangedEventArgs : System.EventArgs
Public Class ProjectItemsChangedEventArgs Inherits System.EventArgs
When the ProjectItemsChangedEvent is fired, ProjectItemsChangedEventArgs is returned to subscribers of the event
//Report the event args when a layout is added. //At 2.x - ArcGIS.Desktop.Layouts.Events.LayoutAddedEvent.Subscribe((args) => //{ // System.Windows.MessageBox.Show("LayoutAddedEvent:" + // Environment.NewLine + // " arg Layout: " + args.Layout.Name); //}); //Use ProjectItemsChangedEvent at 3.x ArcGIS.Desktop.Core.Events.ProjectItemsChangedEvent.Subscribe((args) => { //Layout added. Layout removed would be NotifyCollectionChangedAction.Remove if (args.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add && args.ProjectItem is LayoutProjectItem layoutProjectItem) { var layout_name = layoutProjectItem.Name; var layout = layoutProjectItem.GetLayout(); System.Diagnostics.Debug.WriteLine($"Layout Added: {layout_name}"); } });
//Report the event args when a layout is removed. //At 2.x - ArcGIS.Desktop.Layouts.Events.LayoutRemovedEvent.Subscribe((args) => //{ // System.Windows.MessageBox.Show("LayoutViewEvent:" + // Environment.NewLine + // " arg Layout: " + args.Layout.Name); //}); //Use ProjectItemsChangedEvent at 3.x ArcGIS.Desktop.Core.Events.ProjectItemsChangedEvent.Subscribe((args) => { //Layout added. Layout removed would be NotifyCollectionChangedAction.Remove if (args.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove && args.ProjectItem is LayoutProjectItem layoutProjectItem) { var layout_name = layoutProjectItem.Name; System.Diagnostics.Debug.WriteLine($"Layout Removed: {layout_name}"); } });
//Report the event args when a layout is about to be removed. //At 2.x - ArcGIS.Desktop.Layouts.Events.LayoutRemovingEvent.Subscribe((args) => //{ // if (args.LayoutPath == "CIMPATH=layout.xml") // { // args.Cancel = true; // } // return Task.FromResult(0); //}); //At 3.x use ProjectItemRemovingEvent ArcGIS.Desktop.Core.Events.ProjectItemRemovingEvent.Subscribe((args) => { var layoutItems = args.ProjectItems.ToList().OfType<LayoutProjectItem>() ?? new List<LayoutProjectItem>(); var layoutName = "DontDeleteThisOne"; foreach(var layoutItem in layoutItems) { if (layoutItem.Name == layoutName) { args.Cancel = true;//Cancel the remove break; } } return Task.FromResult(0); });
System.Object
System.EventArgs
ArcGIS.Desktop.Core.Events.ProjectItemsChangedEventArgs
Target Platforms: Windows 11, Windows 10