ArcGIS Pro 修改一个图片element
1 IEnumerable<LayoutProjectItem> layouts = Project.Current.GetItems<LayoutProjectItem>(); 2 foreach (LayoutProjectItem layoutItem in layouts) 3 if (layoutItem != null) 4 { 5 await QueuedTask.Run(() => 6 { 7 Layout layout = layoutItem.GetLayout(); 8 if (layout != null) 9 { 10 if (layout.FindElement("Client Logo") is PictureElement picElm) 11 { 12 if (Equals(Module1.LayoutLogo, picElm.SourcePath.ToString())) 13 { 14 } 15 else 16 { 17 try 18 { 19 if (Module1.LayoutLogo != null) 20 { 21 picElm.SetSourcePath($@"{Module1.LayoutLogo}"); 22 var lyt_cim = layout.GetDefinition(); 23 layout.SetDefinition(lyt_cim); 24 } 25 } 26 catch (Exception) 27 { 28 ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Incorrect Client Logo File Path", "Failure", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning); 29 } 30 } 31 } 32 } 33 }); 34 }