/// <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; } } }
internal static Client.Editor FindEditorInVisualTree() { ESRI.ArcGIS.Client.Editor editor = null; EditorWidget widget = View.Instance.Editor; if (widget != null) { SetEditors(widget); editor = _editor; } return(editor); }
internal static void SetEditorWidget(EditorWidget widget) { SetEditors(widget); }