Exemple #1
0
        private void DrawObject_DrawComplete(object sender, DrawEventArgs e)
        {
            if (this.DrawWidget == this.GetType())
            {
                Graphic graphic = null;

                if (this.drawMode == "Freepoly")
                {
                    // Create a Graphic with the newly closed Polygon
                    graphic = new ESRI.ArcGIS.Client.Graphic()
                    {
                        Geometry = GeometryTool.FreehandToPolygon(e.Geometry as Polyline),
                        Symbol   = this.CurrentApp.Resources[SymbolResources.DRAW_FILL] as FillSymbol
                    };
                }
                else
                {
                    // Create a Graphic with the drawn geometry
                    graphic          = new ESRI.ArcGIS.Client.Graphic();
                    graphic.Geometry = e.Geometry;
                    switch (e.Geometry.GetType().Name)
                    {
                    case "MapPoint":
                        graphic.Symbol = this.CurrentApp.Resources[SymbolResources.DRAW_MARKER] as MarkerSymbol; break;

                    case "Polyline":
                        graphic.Symbol = this.CurrentApp.Resources[SymbolResources.DRAW_LINE] as LineSymbol; break;

                    case "Envelope":
                    case "Polygon":
                        graphic.Symbol = this.CurrentApp.Resources[SymbolResources.DRAW_FILL] as FillSymbol; break;
                    }
                }

                if (lstGeoQueryLayer.SelectedIndex == -1)
                {
                    MessageBox.Show("Please select a feature layer to query against"); return;
                }

                if (this.GraphicsLayer == null)
                {
                    MessageBox.Show("GraphicsLayer for this widget is not created. Please set property HasGraphics 'true'."); return;
                }

                if (graphic != null)
                {
                    this.IsBusy = true;

                    // Temporarily show the draw object
                    this.ClearGraphics(1);
                    this.AddGraphic(graphic);

                    queryTool.QueryLayer = widgetConfig.QueryLayers[lstGeoQueryLayer.SelectedIndex];
                    queryTool.LayerInfo  = (lstGeoQueryLayer.SelectedItem as ComboBoxItem).Tag as ArcGISLayerInfo;
                    queryTool.Search(graphic.Geometry, this.MapSRWKID);
                }
            }
        }
        private void DrawObject_DrawComplete(object sender, DrawEventArgs e)
        {
            if (this.DrawWidget == this.GetType())
            {
                Graphic graphic = null;

                if (this.drawMode == "Freepoly")
                {
                    // Geometry needs to be simplified
                    needGeneralized = true;
                    // Create a Graphic with the newly closed Polygon
                    graphic = new ESRI.ArcGIS.Client.Graphic()
                    {
                        Geometry = GeometryTool.FreehandToPolygon(e.Geometry as Polyline),
                        Symbol   = this.CurrentApp.Resources[SymbolResources.DRAW_FILL] as FillSymbol
                    };
                }
                else
                {
                    // Create a Graphic with the drawn geometry
                    graphic        = new ESRI.ArcGIS.Client.Graphic();
                    graphic.Symbol = this.CurrentApp.Resources[SymbolResources.DRAW_FILL] as FillSymbol;
                    switch (e.Geometry.GetType().Name)
                    {
                    case "Envelope":
                        graphic.Geometry = GeometryTool.EnvelopeToPolygon(e.Geometry as Envelope); break;

                    case "Polygon":
                        graphic.Geometry = e.Geometry; break;
                    }
                }

                if (graphic != null)
                {
                    this.AddGraphic(graphic);
                }
            }
        }
Exemple #3
0
        private void DrawObject_DrawComplete(object sender, DrawEventArgs e)
        {
            if (this.DrawWidget == this.GetType() && e.Geometry != null)
            {
                if (this.measurementMode == MODE_COORD)
                {
                    MapPoint point = e.Geometry as MapPoint;

                    TextLengthResult.Text = string.Format("{0}", Math.Round(point.X, 6));
                    TextAreaResult.Text   = string.Format("{0}", Math.Round(point.Y, 6));
                    Graphic dotGraphic = new Graphic()
                    {
                        Geometry = point, Symbol = this.CurrentApp.Resources[SymbolResources.DRAW_MARKER] as MarkerSymbol
                    };

                    //this.ClearGraphics(-1);
                    AddGraphic(dotGraphic);

                    if (CheckResultOnMap.IsChecked.Value)
                    {
                        string  label      = string.Format("X: {0}\nY: {1}", TextLengthResult.Text, TextAreaResult.Text);
                        Graphic lblGraphic = new Graphic()
                        {
                            Geometry = point, Symbol = new TextSymbol()
                            {
                                Text = label, OffsetX = 0, OffsetY = 30, FontSize = 11.0, Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0xFF))
                            }
                        };
                        AddGraphic(lblGraphic);
                    }
                }
                else
                {
                    this.IsBusy = true;
                    Graphic graphic = null;
                    if (this.DrawObject.DrawMode == DrawMode.Freehand && this.measurementMode == MODE_AREA)
                    {
                        // Create a Graphic with the newly closed Polygon
                        graphic = new ESRI.ArcGIS.Client.Graphic()
                        {
                            Geometry = GeometryTool.FreehandToPolygon(e.Geometry as Polyline),
                            Symbol   = this.CurrentApp.Resources[SymbolResources.DRAW_FILL] as FillSymbol
                        };
                    }
                    else
                    {
                        // Create a Graphic with the drawn geometry
                        graphic          = new ESRI.ArcGIS.Client.Graphic();
                        graphic.Geometry = e.Geometry;
                        switch (e.Geometry.GetType().Name)
                        {
                        case "MapPoint":
                            graphic.Symbol = this.CurrentApp.Resources[SymbolResources.DRAW_MARKER] as MarkerSymbol; break;

                        case "Polyline":
                            graphic.Symbol = this.CurrentApp.Resources[SymbolResources.DRAW_LINE] as LineSymbol; break;

                        case "Polygon":
                            graphic.Symbol = this.CurrentApp.Resources[SymbolResources.DRAW_FILL] as FillSymbol; break;
                        }
                    }

                    if (graphic != null)
                    {
                        //this.ClearGraphics(-1);
                        this.AddGraphic(graphic);
                        DoMesurement(graphic);
                    }
                }
            }
        }