public DrawPolygonToolbar(MapWidget mapWidget, client.FeatureLayer searchAreaFL)
        {
            InitializeComponent();
            DataContext = this;

            #region Initialize the map widget and the search area feature layer
            MapWidget = mapWidget;
            if (!mapWidget.Map.IsInitialized)
            {
                return;
            }
            SearchAreaLayer = searchAreaFL;
            SearchAreaLayer.DisableClientCaching = true;
            #endregion

            #region MapWidget is not null, initialize the editor tool
            Editor = new client.Editor()
            {
                LayerIDs           = new string[] { SearchAreaLayer.ID },
                Map                = mapWidget.Map,
                GeometryServiceUrl = @"http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"
            };
            Editor.EditCompleted   += Editor_EditCompleted;
            Editor.EditorActivated += Editor_EditorActivated;
            #endregion
        }
示例#2
0
 private void MyMap_Loaded(object sender, RoutedEventArgs e)
 {
     ESRI.ArcGIS.Client.Editor myBarrierEditor = LayoutRoot.Resources["MyBarrierEditor"] as ESRI.ArcGIS.Client.Editor;
     myBarrierEditor.Map = MyMap;
     ESRI.ArcGIS.Client.Editor myFacilityEditor = LayoutRoot.Resources["MyFacilityEditor"] as ESRI.ArcGIS.Client.Editor;
     myFacilityEditor.Map = MyMap;
 }
示例#3
0
        /// <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;
                }
            }
        }
示例#4
0
        private static void EditPoint(ESRI.ArcGIS.Client.Editor editor, Graphic graphic)
        {
            StopPointEditing(editor.Map);

            graphic.Selected             = true;
            _editedGraphic               = graphic;
            graphic.MouseLeftButtonDown += EditedPointGraphicMouseLeftButtonDown;
            graphic.MouseLeftButtonUp   += EditedPointGraphicMouseLeftButtonUp;
            editor.Map.MouseClick       += Map_MouseClick;
            editor.Map.MouseMove        += Map_MouseMove;
        }
示例#5
0
        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);
        }
示例#6
0
        public static void StopEditing()
        {
            if (_editGeometry != null)
            {
                _editGeometry.StopEdit();
            }

            ESRI.ArcGIS.Client.Editor editor = FindEditorInVisualTree();
            if (editor.CancelActive.CanExecute(null))
            {
                editor.CancelActive.Execute(null);
            }
        }
示例#7
0
        public static void EditShape(OnClickPopupInfo popupInfo, ESRI.ArcGIS.Client.Editor editor = null, bool dismissPopup = false)
        {
            if (popupInfo == null)
            {
                return;
            }

            if (editor == null)
            {
                editor = FindEditorInVisualTree();
            }

            PopupItem popup = popupInfo.PopupItem;

            if (popup == null && popupInfo.PopupItems != null && popupInfo.PopupItems.Count >= 1)
            {
                popup = popupInfo.PopupItems[0];
            }

            if (!CanEditShape(popup, editor))
            {
                return;
            }

            Graphic graphic      = popup.Graphic;
            var     featureLayer = popup.Layer as FeatureLayer;

            if (featureLayer != null && featureLayer.LayerInfo != null)
            {
                // Dismiss popup so it does not get in the way of shape edits
                InfoWindow container = popupInfo.Container as InfoWindow;
                if (container != null && dismissPopup)
                {
                    container.IsOpen = false;
                }

                if (featureLayer.LayerInfo.GeometryType == GeometryType.Polygon ||
                    featureLayer.LayerInfo.GeometryType == GeometryType.Polyline ||
                    featureLayer.LayerInfo.GeometryType == GeometryType.MultiPoint)
                {
                    EditGeometry(graphic, featureLayer);
                }
                else if (featureLayer.LayerInfo.GeometryType == Client.Tasks.GeometryType.Point)
                {
                    // edit point using Editor
                    EditPoint(editor, graphic);
                }
            }
        }
示例#8
0
        public static bool CanEditShape(PopupItem popup, ESRI.ArcGIS.Client.Editor editor = null)
        {
            if (editor == null)
            {
                editor = FindEditorInVisualTree();
            }
            var featureLayer = popup.Layer as FeatureLayer;

            if (popup == null ||
                popup.Graphic == null ||
                featureLayer == null ||
                featureLayer.LayerInfo == null ||
                !featureLayer.IsGeometryUpdateAllowed(popup.Graphic) ||
                !(LayerProperties.GetIsEditable(featureLayer)) ||
                editor == null ||
                editor.EditVertices == null ||
                !editor.EditVerticesEnabled ||
                View.Instance.Map == null)
            {
                return(false);
            }

            return(true);
        }
        public DrawPolygonToolbar(MapWidget mapWidget, client.FeatureLayer searchAreaFL)
        {
            InitializeComponent();
             DataContext = this;

             #region Initialize the map widget and the search area feature layer
             MapWidget = mapWidget;
             if (!mapWidget.Map.IsInitialized)
            return;
             SearchAreaLayer = searchAreaFL;
             SearchAreaLayer.DisableClientCaching = true;
             #endregion

             #region MapWidget is not null, initialize the editor tool
             Editor = new client.Editor()
             {
            LayerIDs = new string[] { SearchAreaLayer.ID },
            Map = mapWidget.Map,
            GeometryServiceUrl = @"http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"
             };
             Editor.EditCompleted += Editor_EditCompleted;
             Editor.EditorActivated += Editor_EditorActivated;
             #endregion
        }
        /// <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;
                }
            }
        }
 /// <summary>
 ///  OnDeactivated is called before the toolbar is uninstalled from the map widget.
 /// </summary>
 public void OnDeactivated()
 {
     Editor = null;
     SearchAreaAttributes = null;
     NewSearchArea        = null;
 }
 /// <summary>
 ///  OnDeactivated is called before the toolbar is uninstalled from the map widget. 
 /// </summary>
 public void OnDeactivated()
 {
     Editor = null;
      SearchAreaAttributes = null;
      NewSearchArea = null;
 }