private static void OnMapPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { Map oldMap = e.OldValue as Map; Map newMap = e.NewValue as Map; EditorWidget widget = (EditorWidget)d; if (widget != null) { widget.editor.Map = newMap; if (oldMap != null && oldMap.Layers != null) { List <GraphicsLayer> oldGraphicsLayers = new List <GraphicsLayer>(); foreach (Layer layer in oldMap.Layers) { if (layer is GraphicsLayer) { oldGraphicsLayers.Add(layer as GraphicsLayer); } } widget.DetachLayerEventHandlers(oldGraphicsLayers); oldMap.Layers.CollectionChanged -= widget.Layers_CollectionChanged; } if (newMap != null && newMap.Layers != null) { newMap.Layers.CollectionChanged += widget.Layers_CollectionChanged; widget.AttachLayerEventHandlers(widget.editor.GraphicsLayers); } } }
private static void OnShowAttributesOnAddPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { bool newValue = (bool)e.NewValue; EditorWidget widget = (EditorWidget)d; if (widget != null && widget.TemplatePicker != null) { widget.TemplatePicker.ShowAttributesOnAdd = newValue; } }
private static void OnLayerIdsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { EditorWidget widget = (d as EditorWidget); if (widget != null) { widget.DetachLayerEventHandlers(widget.editor.GraphicsLayers); widget.editor.LayerIDs = widget.LayerIDs; widget.AttachLayerEventHandlers(widget.editor.GraphicsLayers); } }
internal static void SetEditorWidget(EditorWidget widget) { SetEditors(widget); }
/// <summary> /// Sets the editors if the widget is non-null. Otherwise, /// current editor settings and event handlers are left intact. /// </summary> private static void SetEditors(EditorWidget widget) { if (widget == null || widget.DataContext == null) return; // set the widget event hookup bool widgetExists = false; if (_widget != null) { if (widget != _widget) { // unhook the event handler from the previous editor _widget.EditCompleted -= OnEditorWidgetEditCompleted; } else widgetExists = true; } if (!widgetExists) { // set our editor to the newly found one _widget = widget; _widget.EditCompleted -= OnEditorWidgetEditCompleted; _widget.EditCompleted += OnEditorWidgetEditCompleted; } // manage the editor event hookup ESRI.ArcGIS.Client.Editor editor = widget.DataContext as ESRI.ArcGIS.Client.Editor; if (editor != null) { bool existing = false; // check the last editor if (_editor != null) { if (editor != _editor) { // unhook the event handler from the previous editor _editor.EditCompleted -= OnEditorEditCompleted; } else existing = true; } if (!existing) { // set our editor to the newly found one _editor = editor; _editor.EditCompleted -= OnEditorEditCompleted; _editor.EditCompleted += OnEditorEditCompleted; } } }