Exemplo n.º 1
0
        private async void StartDraw()
        {
            if (!IsEnable && MapEditor == null && layer == null)
            {
                return;
            }
            GraphicsLayer drawLayer = layer; // Fix Bug, change layer during drawing
            DrawOptionVm  optionVm  = null;

            foreach (var opt in drawOptions)
            {
                if (opt.IsChecked)
                {
                    optionVm = opt;
                    break;
                }
            }

            if (optionVm != null)
            {
                try
                {
                    var progress = new Progress <GeometryEditStatus>();

                    var result = await MapEditor.RequestShapeAsync(optionVm.Shape, null, progress);

                    var graphic = new Graphic
                    {
                        Geometry = result,
                        Symbol   = optionVm.Symbol
                    };
                    foreach (var item in optionVm.Attributes)
                    {
                        graphic.Attributes.Add(item.Key, item.Value);
                    }
                    drawLayer.Graphics.Add(graphic);
                }
                catch (TaskCanceledException)
                {
                }
                catch (Exception ex)
                {
                    Reset();
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemplo n.º 2
0
        public DrawOptionsGroupVm()
        {
            var polylineSymbol = new SimpleLineSymbol
            {
                Color = Colors.Red,
                Width = 2
            };

            DrawPolyLine = new DrawOptionVm(DrawShape.Polyline, polylineSymbol);
            var contourSymbol = new SimpleLineSymbol
            {
                Color = Colors.Purple,
                Width = 2
            };

            DrawContour = new DrawOptionVm(DrawShape.Polyline, contourSymbol);
            DrawPolyLine.Attributes.Add(Diamond14Attributes.LineType, Diamond14Attributes.LineTypeLine);
            DrawContour.Attributes.Add(Diamond14Attributes.LineType, Diamond14Attributes.LineTypeContour);

            var polygonSymbol = new SimpleFillSymbol
            {
                Color = Color.FromArgb(0x66, 0xff, 0, 0)
            };

            DrawPolygon = new DrawOptionVm(DrawShape.Polygon, polygonSymbol);

            var pointSymbol = new SimpleMarkerSymbol
            {
                Style = SimpleMarkerStyle.Circle
            };

            DrawPoint = new DrawOptionVm(DrawShape.Point, pointSymbol);

            drawOptions.Add(DrawPoint);
            drawOptions.Add(DrawPolygon);
            drawOptions.Add(DrawPolyLine);
            drawOptions.Add(DrawContour);

            StartDrawCommand     = new DelegateCommand(StartDraw);
            StartEditCommand     = new DelegateCommand(StartEdit);
            DeleteGraphicCommand = new DelegateCommand(DeleteGraphic);
            UpdateValueCommand   = new DelegateCommand(UpdateValue);
            //IsEnabledChangedCommand = new DelegateCommand<bool?>(IsEnabledChanged);
            //CompleteCommand = new DelegateCommand(Complete, CanComplete);
            //CancelCommand = new DelegateCommand(Cancel, CanCancel);
        }