예제 #1
0
        //public async void drawToolsClickEventListener(object sender,
        //    UserControl.DrawToolClickEventArgs args)
        //{
        //    if (args.stopDraw)
        //    {
        //        if (_mapView.Editor.Cancel.CanExecute(null))
        //            _mapView.Editor.Cancel.Execute(null);
        //    }
        //    else
        //    {
        //        await drawGraphics(args.drawShapeType);
        //    }
        //}

        public async Task drawGraphics(DrawShapeType drawShapeType)
        {
            if (Globals.isThreadUnsafe())
            {
                await Globals.application.Dispatcher.Invoke(new Func <Task>(async() =>
                {
                    await drawGraphics(drawShapeType);
                }));

                return;
            }

            // Add a drawing graphics layer
            if (_drawingLayer == null)
            {
                _drawingLayer             = new IS3GraphicsLayer();
                _drawingLayer.ID          = "0";
                _drawingLayer.DisplayName = "0";
                _map.Layers.Add(_drawingLayer);
            }

            if (_mapView.Editor.IsActive)
            {
                return;
            }

            try
            {
                Geometry geom = await _mapView.Editor.RequestShapeAsync((DrawShape)drawShapeType);

                if (_srEMap != null)
                {
                    geom = GeometryEngine.Project(geom, _srEMap);
                }
                IGeometry iGeom = IS3GeometryEngine.fromGeometry(geom);
                IGraphic  g     = Runtime.graphicEngine.newGraphic(iGeom);
                GraphicsUtil.AssignDefaultDrawingSymbol(g);

                _drawingLayer.graphics.Add(g);

                // trigger a drawing graphics changed event
                if (drawingGraphicsChangedTrigger != null)
                {
                    DrawingGraphicsChangedEventArgs args =
                        new DrawingGraphicsChangedEventArgs();
                    List <IGraphic> addedItems = new List <IGraphic>();
                    addedItems.Add(g);
                    args.addedItems = addedItems;
                    drawingGraphicsChangedTrigger(this, args);
                }
            }
            catch (TaskCanceledException)
            {
                // Ignore TaskCanceledException - usually happens if the editor gets cancelled or restarted
            }
        }
예제 #2
0
        public async void selectByRect()
        {
            if (Globals.isThreadUnsafe())
            {
                Globals.application.Dispatcher.Invoke(new Action(() =>
                {
                    selectByRect();
                }));
                return;
            }

            Geometry geom = await _mapView.Editor.RequestShapeAsync(DrawShape.Rectangle);

            if (_srEMap != null)
            {
                geom = GeometryEngine.Project(geom, _srEMap);
            }
            IGeometry rect = IS3GeometryEngine.fromGeometry(geom);

            ObjSelectionChangedEventArgs args = new ObjSelectionChangedEventArgs();

            args.addedObjs = new Dictionary <string, IEnumerable <DGObject> >();

            foreach (Layer layer in _map.Layers)
            {
                IGraphicsLayer gLayer = layer as IGraphicsLayer;
                if (!isLayerSelectable(gLayer))
                {
                    continue;
                }
                List <DGObject> objs = gLayer.selectObjectsByRect(rect);
                if (objs.Count > 0)
                {
                    //old
                    // args.addedObjs.Add(gLayer.ID, objs);
                    args.addedObjs.Add(objs.FirstOrDefault().parent.definition.Name, objs);
                }
            }

            if (objSelectionChangedTrigger != null)
            {
                objSelectionChangedTrigger(this, args);
            }
        }
예제 #3
0
        //   Construct from a Esri.ArcGISRuntime.Geometry.Geometry instance.
        public IS3Graphic(Esri.ArcGISRuntime.Geometry.Geometry g)
        {
            IGeometry ig = IS3GeometryEngine.fromGeometry(g);

            base.Geometry = ig as Esri.ArcGISRuntime.Geometry.Geometry;
        }