private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            FeatureLayer featureLayer = MyMap.Layers["MyFeatureLayer"] as FeatureLayer;
            System.Windows.Point screenPnt = MyMap.MapToScreen(e.MapPoint);

            // Account for difference between Map and application origin
            GeneralTransform generalTransform = MyMap.TransformToVisual(Application.Current.RootVisual);
            System.Windows.Point transformScreenPnt = generalTransform.Transform(screenPnt);

            IEnumerable<Graphic> selected =
                featureLayer.FindGraphicsInHostCoordinates(transformScreenPnt);

            foreach (Graphic g in selected)
            {

                MyInfoWindow.Anchor = e.MapPoint;
                MyInfoWindow.IsOpen = true;
                //Since a ContentTemplate is defined, Content will define the DataContext for the ContentTemplate
                MyInfoWindow.Content = g.Attributes;
                return;
            }

            InfoWindow window = new InfoWindow()
            {
                Anchor = e.MapPoint,
                Map = MyMap,
                IsOpen = true,
                Placement=InfoWindow.PlacementMode.Auto,
                ContentTemplate = LayoutRoot.Resources["LocationInfoWindowTemplate"] as System.Windows.DataTemplate,
                //Since a ContentTemplate is defined, Content will define the DataContext for the ContentTemplate
                Content = e.MapPoint
            };
            LayoutRoot.Children.Add(window);
        }
Ejemplo n.º 2
1
        private void axSceneControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ISceneControlEvents_OnMouseDownEvent e)
        {
            IPoint pPoint = null;
            object objOwner = null;
            object objObject = null;

            axSceneControl1.SceneGraph.Locate(axSceneControl1.SceneViewer, e.x, e.y, esriScenePickMode.esriScenePickGeography, true, out pPoint, out objOwner, out objObject);

            ITextElement pTextElement = new TextElementClass();
            pTextElement.Text = "dddddd";

            IGraphicsContainer3D pGCon3D = axSceneControl1.Scene.BasicGraphicsLayer as IGraphicsContainer3D;
            IElement  pElement = new MarkerElementClass();
            IMarkerElement pPointElement = pElement as MarkerElementClass;
            ILineElement pLineElement = pElement as ILineElement;
            ISimpleLineSymbol pLSymbol = new SimpleLineSymbolClass();
            ISimpleMarkerSymbol pMSym = new SimpleMarkerSymbolClass();
            IColor pFromColor = new RgbColorClass();
            IRgbColor pRgbColor = pFromColor as IRgbColor;
            pRgbColor.Red = 255;
            pRgbColor.Green = 0;
            pRgbColor.Blue = 0;
            pMSym.Size = 10;
            pMSym.Color = pFromColor;
            pMSym.Style = esriSimpleMarkerStyle.esriSMSDiamond;
            pPointElement.Symbol = pMSym;
            pLSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
            pElement.Geometry = pPoint;

            pGCon3D.AddElement(pElement as IElement );
            axSceneControl1.Scene.SceneGraph.RefreshViewers();
            IDisplay3D pIDisplay3D = axSceneControl1.Scene.SceneGraph as IDisplay3D ;
            pIDisplay3D.FlashLocation(pPoint);
        }
        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            _geometryService.CancelAsync();
            _queryTask.CancelAsync();

            Graphic clickGraphic = new Graphic();
            clickGraphic.Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
            clickGraphic.Geometry = e.MapPoint;
            // Input spatial reference for buffer operation defined by first feature of input geometry array
            clickGraphic.Geometry.SpatialReference = MyMap.SpatialReference;

            _pointAndBufferGraphicsLayer.ClearGraphics();
            _resultsGraphicsLayer.ClearGraphics();

            clickGraphic.SetZIndex(2);
            _pointAndBufferGraphicsLayer.Graphics.Add(clickGraphic);

            // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
            ESRI.ArcGIS.Client.Tasks.BufferParameters bufferParams = new ESRI.ArcGIS.Client.Tasks.BufferParameters()
            {
                BufferSpatialReference = new SpatialReference(4326),
                OutSpatialReference = MyMap.SpatialReference,
                Unit = LinearUnit.Meter,
            };
            bufferParams.Distances.Add(100);
            bufferParams.Features.Add(clickGraphic);

            _geometryService.BufferAsync(bufferParams);
        }
        private void MyMap_MapGesture(object sender, ESRI.ArcGIS.Client.Map.MapGestureEventArgs e)
        {
            if (e.Gesture == GestureType.Tap)
            {
                FeatureLayer featureLayer = MyMap.Layers["MyFeatureLayer"] as FeatureLayer;
                IEnumerable<Graphic> selected = e.DirectlyOver(10,  new GraphicsLayer[] { featureLayer });
                foreach (Graphic g in selected)
                {
                    MyInfoWindow.Anchor = e.MapPoint;
                    MyInfoWindow.IsOpen = true;
                    //Since a ContentTemplate is defined (in XAML), Content will define the DataContext for the ContentTemplate
                    MyInfoWindow.Content = g;
                    return;
                }

                InfoWindow window = new InfoWindow()
                {
                    Anchor = e.MapPoint,
                    Padding = new Thickness(3),
                    Map = MyMap,
                    IsOpen = true,
                    Placement = InfoWindow.PlacementMode.Auto,
                    ContentTemplate = LayoutRoot.Resources["LocationInfoWindowTemplate"] as System.Windows.DataTemplate,
                    //Since a ContentTemplate is defined, Content will define the DataContext for the ContentTemplate
                    Content = new ESRI.ArcGIS.Client.Geometry.MapPoint(
                        double.Parse(e.MapPoint.X.ToString("0.000")),
                        double.Parse(e.MapPoint.Y.ToString("0.000")))
                };
                LayoutRoot.Children.Add(window);
            }
        }
        public override void Initialize(ESRI.ArcLogistics.App.Pages.Page page)
        {
            label1.Content = "Data unavailable.";
            try
            {
                string URLString = @"http://www.weather.gov/xml/current_obs/KRAL.xml";
                XmlTextReader reader = new XmlTextReader(URLString);

                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "temperature_string")
                    {
                        if (reader.Read())
                            label1.Content = "Riverside, CA: " + reader.Value;

                        reader.Close();
                        break;
                    }
                }
            }

            finally
            {

            }
        }
 private void GraphicsLayer_MouseLeftButtonDown(object sender, ESRI.ArcGIS.Client.GraphicMouseButtonEventArgs e)
 {
     if (e.Graphic.Selected)
         e.Graphic.UnSelect();
     else
         e.Graphic.Select();
 }
Ejemplo n.º 7
0
        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            CsvLayer csvLayer = MyMap.Layers["MyCSVLayer"] as CsvLayer;
            System.Windows.Point screenPnt = MyMap.MapToScreen(e.MapPoint);

            // Account for difference between Map and application origin
            GeneralTransform generalTransform = MyMap.TransformToVisual(null);
            System.Windows.Point transformScreenPnt = generalTransform.Transform(screenPnt);

            int tolerance = 20;
            Rect screenRect = new Rect(new Point(transformScreenPnt.X - tolerance / 2, transformScreenPnt.Y - tolerance / 2),
                new Point(transformScreenPnt.X + tolerance / 2, transformScreenPnt.Y + tolerance / 2));
            IEnumerable<Graphic> selected =
                csvLayer.FindGraphicsInHostCoordinates(screenRect);

            foreach (Graphic g in selected)
            {

                MyInfoWindow.Anchor = e.MapPoint;
                MyInfoWindow.IsOpen = true;
                //Since a ContentTemplate is defined, Content will define the DataContext for the ContentTemplate
                MyInfoWindow.Content = g.Attributes;
                return;
            }
        }
        private void LocatorTask_AddressToLocationsCompleted(object sender, ESRI.ArcGIS.Client.Tasks.AddressToLocationsEventArgs args)
        {
            List<AddressCandidate> returnedCandidates = args.Results;

            AddressBorder.Visibility = System.Windows.Visibility.Collapsed;

            if (returnedCandidates.Count > 0)
            {
                AddressCandidate candidate = returnedCandidates[0];

                Graphic graphic = new Graphic()
                {
                    Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as Symbol,
                    Geometry = candidate.Location
                };

                graphic.Attributes.Add("Address", candidate.Address);

                graphicsLayer.Graphics.Add(graphic);

                ResultsTextBlock.Visibility = System.Windows.Visibility.Visible;
                ResultsTextBlock.Text = candidate.Address;

                double displaySize = MyMap.MinimumResolution * 30;
                ESRI.ArcGIS.Client.Geometry.Envelope displayExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(
                    candidate.Location.X - (displaySize / 2),
                    candidate.Location.Y - (displaySize / 2),
                    candidate.Location.X + (displaySize / 2),
                    candidate.Location.Y + (displaySize / 2));
                MyMap.ZoomTo(displayExtent);
            }
        }
 private void Legend_Refreshed(object sender, ESRI.ArcGIS.Client.Toolkit.Legend.RefreshedEventArgs e)
 {
     if (e.LayerItem.LayerItems != null)
         foreach (LayerItemViewModel layerItemVM in e.LayerItem.LayerItems)
             if (layerItemVM.IsExpanded)
                 layerItemVM.IsExpanded = false;
 }
        void addInput(ESRI.ArcGIS.Client.Geometry.Geometry geometry)
        {
            GraphicsLayer layer = getLayer();

            #region Create layer if not already there and add to map
            if (layer == null)
            {
                InputLayerID = Guid.NewGuid().ToString("N");
                layer = new GraphicsLayer();
                if (config.Layer != null)
                {
                    layer.Renderer = config.Layer.Renderer;
                    Core.LayerExtensions.SetFields(layer, Core.LayerExtensions.GetFields(config.Layer));
                    Core.LayerExtensions.SetGeometryType(layer, Core.LayerExtensions.GetGeometryType(config.Layer));
                    Core.LayerExtensions.SetDisplayField(layer, Core.LayerExtensions.GetDisplayField(config.Layer));
                    Core.LayerExtensions.SetPopUpsOnClick(layer, Core.LayerExtensions.GetPopUpsOnClick(config.Layer));
                    LayerProperties.SetIsPopupEnabled(layer, LayerProperties.GetIsPopupEnabled(config.Layer));
                }
                layer.ID = InputLayerID;

                layer.SetValue(MapApplication.LayerNameProperty,
                    string.IsNullOrEmpty(config.LayerName) ? 
                        string.IsNullOrEmpty(config.Label) ? config.Name : config.Label
                        : config.LayerName);
                layer.Opacity = config.Opacity;
                Map.Layers.Add(layer);
            }
            #endregion

            #region Add geometry to layer
            Graphic g = new Graphic() { Geometry = geometry };
            layer.Graphics.Add(g);
            #endregion
        }
        private void MyDrawObject_DrawComplete(object sender, ESRI.ArcGIS.Client.DrawEventArgs e)
        {
            MyDrawObject.IsEnabled = false;

            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
            graphicsLayer.ClearGraphics();

            Graphic graphic = new Graphic()
            {
                Symbol = LayoutRoot.Resources["StartMarkerSymbol"] as Symbol,
                Geometry = e.Geometry as MapPoint
            };
            graphicsLayer.Graphics.Add(graphic);

            Geoprocessor geoprocessorTask = new Geoprocessor("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/" +
                "Specialty/ESRI_Currents_World/GPServer/MessageInABottle");
            geoprocessorTask.ExecuteCompleted += GeoprocessorTask_ExecuteCompleted;
            geoprocessorTask.Failed += GeoprocessorTask_Failed;

            List<GPParameter> parameters = new List<GPParameter>();
            parameters.Add(new GPFeatureRecordSetLayer("Input_Point", e.Geometry as MapPoint));
            parameters.Add(new GPDouble("Days", Convert.ToDouble(DaysTextBox.Text)));

            geoprocessorTask.ExecuteAsync(parameters);
        }
 //保存地图文档
 public static void SaveMapDocument(ESRI.ArcGIS.Controls.AxMapControl axMapControl)
 {
     if (axMapControl == null)
     {
         return;
     }
     string m_mapDocumentName = axMapControl.DocumentFilename;
     if (axMapControl.CheckMxFile(m_mapDocumentName))
     {
         //新建地图文档接口
         IMapDocument mapDoc = new MapDocumentClass();
         mapDoc.Open(m_mapDocumentName, string.Empty);
         //确定文档非只读文件
         if (mapDoc.get_IsReadOnly(m_mapDocumentName))
         {
             MessageBox.Show("Map document is read only!");
             mapDoc.Close();
             return;
         }
         //用当前地图替换文档内容
         mapDoc.ReplaceContents((IMxdContents)axMapControl.Map);
         //保存文档
         mapDoc.Save(mapDoc.UsesRelativePaths, false);
         //关闭文档
         mapDoc.Close();
     }
 }
        public override object getTransformedValue(ESRI.ArcGIS.DataSourcesRaster.IPixelBlock3 bigArr, int startClm, int startRw, int nBand)
        {
            //Console.WriteLine("Start CR = " + startClm.ToString()+":"+ startRw.ToString());
            float s = 0;
            float s2 = 0;
            foreach (int[] xy in offsetLst)
            {
                int bWc = xy[0] + startClm;
                int bRc = xy[1] + startRw;

                object vlObj = bigArr.GetVal(nBand, bWc, bRc);

                if (vlObj == null)
                {
                    continue;
                }
                else
                {
                    float vl = (float)vlObj;
                    s += vl;
                    s2 += vl * vl;
                }
            }
            return (s2 - ((s * s) / offsetLst.Count)) / offsetLst.Count;
        }
        protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            if (arg.Button != System.Windows.Forms.MouseButtons.Left)
                return;
            try
            {
                //Get the active view from the ArcMap static class.
                IActiveView activeView = ArcMap.Document.FocusMap as IActiveView;

                var point = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y) as IPoint;

                // always use WGS84
                var sr = GetSR();

                if (sr != null)
                {
                    point.Project(sr);
                }

                var doc = AddIn.FromID<ArcMapAddinCoordinateTool.DockableWindowCoordinateTool.AddinImpl>(ThisAddIn.IDs.DockableWindowCoordinateTool);

                if (doc != null)
                {
                    doc.SetInput(point.X, point.Y);
                }
            }
            catch { }
        }
Ejemplo n.º 15
0
        private void CacheSnapObjects(ESRI.ArcGIS.Client.Geometry.Geometry geometryObject, double snapDistance)
        {
            // For the given geometry (line or circle), find all the features that fall within the snapDistance.
              // First we need to issue a buffer in this method. GeometryService_LineBufferCompleted will
              // do the feature query.

              _snapObjects.Clear();
              GeometryService geometryServiceScaleRotate = new GeometryService(_xmlConfiguation.GeometryServerUrl);
              if (geometryServiceScaleRotate == null)
            return;

              geometryServiceScaleRotate.BufferCompleted += GeometryService_LineBufferCompleted;
              geometryServiceScaleRotate.Failed += GeometryService_Failed;
              geometryServiceScaleRotate.CancelAsync();

              Graphic clickGraphic = new Graphic();
              clickGraphic.Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
              clickGraphic.Geometry = geometryObject;

              // Input spatial reference for buffer operation defined by first feature of input geometry array
              clickGraphic.Geometry.SpatialReference = ParcelMap.SpatialReference;

              // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
              ESRI.ArcGIS.Client.Tasks.BufferParameters bufferParams = new ESRI.ArcGIS.Client.Tasks.BufferParameters()
              {
            BufferSpatialReference = ParcelMap.SpatialReference,
            OutSpatialReference = ParcelMap.SpatialReference,
              };
              bufferParams.Distances.Add(snapDistance);
              bufferParams.Features.Add(clickGraphic);

              System.Diagnostics.Debug.WriteLine("Async: Buffering potential candidates for snapping.");
              geometryServiceScaleRotate.BufferAsync(bufferParams, snapDistance);
        }
        public void Execute(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.esriSystem.ITrackCancel TrackCancel, ESRI.ArcGIS.Geoprocessing.IGPEnvironmentManager envMgr, ESRI.ArcGIS.Geodatabase.IGPMessages message)
        {
            try
            {
                IGPUtilities3 gpUtilities3 = new GPUtilitiesClass();

                if (TrackCancel == null)
                {
                    TrackCancel = new CancelTrackerClass();
                }

                IGPParameter inputFeatureClassParameter = paramvalues.get_Element(in_osmFeaturesNumber) as IGPParameter;
                IGPValue inputFeatureGPValue = gpUtilities3.UnpackGPValue(inputFeatureClassParameter) as IGPValue;

                IFeatureClass osmFeatureClass = null;
                IQueryFilter queryFilter = null;

                gpUtilities3.DecodeFeatureLayer((IGPValue)inputFeatureGPValue, out osmFeatureClass, out queryFilter);

                ((ITable)osmFeatureClass).ApplyOSMClassExtension();
            }
            catch (Exception ex)
            {
                message.AddError(120050, ex.Message);
            }
        }
Ejemplo n.º 17
0
        static string _doubleFormat = "F6"; // XML precision

        #endregion Fields

        #region Methods

        public static bool WriteCEXML(ref ParcelData parcelData, string xmlFileName, ref Configuration configuration, ESRI.ArcGIS.Client.Geometry.SpatialReference spatialReference, ref PointDictionary pointDictionary, ref MapPoint projectedStartPoint, double scale, double rotation)
        {
            DocumentEntry documentType = parcelData.DocumentEntries.CurrentItem as DocumentEntry; ;

              XmlWriterSettings settings = new XmlWriterSettings();
              settings.Indent = true;
              settings.IndentChars = "  ";
              settings.NewLineChars = "\r\n";
              settings.NewLineHandling = NewLineHandling.Replace;

              XmlWriter writer = XmlWriter.Create(xmlFileName, settings);
              if (writer == null)
            return false;

              writer.WriteStartDocument();
              writer.WriteStartElement("geodata", "GeoSurveyPacketData", @"http://www.geodata.com.au/schemas/GeoSurvey/ESRI/1.0/");
              writer.WriteElementString("schemaVersion", "2.0");

              WriteUnits(ref writer, ref spatialReference, ref configuration);
              WriteJobParameters(ref writer, ref configuration);
              WritePlans(ref writer, ref parcelData, ref pointDictionary, ref projectedStartPoint, scale, rotation, ref configuration, ref documentType);
              WritePoints(ref writer);
              WriteControl(ref writer);

              writer.WriteEndElement();
              writer.WriteEndDocument();
              writer.Dispose();             // force write of item.

              return true;
        }
Ejemplo n.º 18
0
 public Print(ESRI.ArcGIS.Controls.AxMapControl AxMap)
 {
     axMap = AxMap;
     InitializeComponent();
     Common.MapPrintCommon.g_axPageLayoutControl = axPageLayoutControl1;
     Common.MapPrintCommon.g_axToolbarControl = axToolbarControl1;
 }
 private void FeatureLayer_PointerMoved(object sender, ESRI.ArcGIS.Runtime.Xaml.GraphicPointerRoutedEventArgs e)
 {
     FeatureLayer layer = sender as FeatureLayer;
     eventTb.Text = "Moved";
     layerTb.Text = layer.DisplayName;
     graphicIdTb.Text = string.Format("{0}", e.Graphic.Attributes[layer.ServiceInfo.ObjectIdField]);
 }
Ejemplo n.º 20
0
        private void axPageLayoutControl1_OnDoubleClick(object sender, ESRI.ArcGIS.Controls.IPageLayoutControlEvents_OnDoubleClickEvent e)
        {
            if (e.button == 1)
            {
                //标注的修改
                if (axPageLayoutControl1.CurrentTool == null) return;
                if (((axPageLayoutControl1.CurrentTool) as ICommand).Name == "ControlToolsGraphicElement_SelectTool")
                {
                    IPoint pPoint = new PointClass();
                    pPoint.PutCoords(e.pageX, e.pageY);

                    IGraphicsContainer pGraphicsContainer = axPageLayoutControl1.PageLayout as IGraphicsContainer;

                    IEnumElement pEnumElement = pGraphicsContainer.LocateElements(pPoint, 10);
                    if (pEnumElement != null)
                    {
                        IElement pElement = pEnumElement.Next();
                        if (pElement is ITextElement)
                        {
                            ITextElement ptextElement = pElement as ITextElement;
                            MapPrint.TextSetUp textSetUp = new MapPrint.TextSetUp();
                            textSetUp.UpdateTextElement(ptextElement);
                            textSetUp.Show();
                        }
                    }

                }
            }
        }
        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
              graphicsLayer.ClearGraphics();

              e.MapPoint.SpatialReference = MyMap.SpatialReference;
              Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
              {
            Geometry = e.MapPoint,
            Symbol = LayoutRoot.Resources["DefaultClickSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
              };
              graphic.SetZIndex(1);
              graphicsLayer.Graphics.Add(graphic);

              GeometryService geometryService =
            new GeometryService("http://serverapps101.esri.com/arcgis/rest/services/Geometry/GeometryServer");
              geometryService.BufferCompleted += GeometryService_BufferCompleted;
              geometryService.Failed += GeometryService_Failed;

              // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
              BufferParameters bufferParams = new BufferParameters()
              {
            Unit = chkGeodesic.IsChecked.HasValue && chkGeodesic.IsChecked.Value ? LinearUnit.StatuteMile : (LinearUnit?)null,
            BufferSpatialReference = new SpatialReference(4326),
            OutSpatialReference = MyMap.SpatialReference
              };
              bufferParams.Features.Add(graphic);
              bufferParams.Distances.Add(5);
              bufferParams.Geodesic = chkGeodesic.IsChecked == true ? true : false;

              geometryService.BufferAsync(bufferParams);
        }
        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            MapPoint geographicPoint = _mercator.ToGeographic(e.MapPoint) as MapPoint;

            string SOEurl = "http://sampleserver4.arcgisonline.com/ArcGIS/rest/services/Elevation/ESRI_Elevation_World/MapServer/exts/ElevationsSOE/ElevationLayers/1/GetElevationAtLonLat";
            SOEurl += string.Format(System.Globalization.CultureInfo.InvariantCulture, "?lon={0}&lat={1}&f=json", geographicPoint.X, geographicPoint.Y);

            WebClient webClient = new WebClient();

            webClient.OpenReadCompleted += (s, a) =>
            {
                var sr = new StreamReader(a.Result);
                string str = sr.ReadToEnd();

                JObject jsonResponse = JObject.Parse(str);
                double elevation = (double)jsonResponse["elevation"];
                a.Result.Close();

                MyInfoWindow.Anchor = e.MapPoint;
                MyInfoWindow.Content = string.Format("Elevation: {0} meters", elevation.ToString("0"));
                MyInfoWindow.IsOpen = true;
            };

            webClient.OpenReadAsync(new Uri(SOEurl));
        }
        private void QueryPoint_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            ESRI.ArcGIS.Client.Geometry.MapPoint clickPoint = e.MapPoint;

            ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
            {
                Geometry = clickPoint,
                MapExtent = MyMap.Extent,
                Width = (int)MyMap.ActualWidth,
                Height = (int)MyMap.ActualHeight,
                LayerOption = LayerOption.visible,
                SpatialReference = MyMap.SpatialReference
            };

            IdentifyTask identifyTask = new IdentifyTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/" +
                "Demographics/ESRI_Census_USA/MapServer");
            identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
            identifyTask.Failed += IdentifyTask_Failed;
            identifyTask.ExecuteAsync(identifyParams);

            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
            graphicsLayer.ClearGraphics();
            ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
            {
                Geometry = clickPoint,
                Symbol = LayoutRoot.Resources["DefaultPictureSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
            };
            graphicsLayer.Graphics.Add(graphic);
        }
        private void MyDrawSurface_DrawComplete(object sender, ESRI.ArcGIS.Client.DrawEventArgs args)
        {
            ResultsDisplay.Visibility = Visibility.Collapsed;
            MyDrawObject.IsEnabled = false;
            selectionGraphicslayer.ClearGraphics();

            QueryTask queryTask = new QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5");
            queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;
            queryTask.Failed += QueryTask_Failed;

            // Bind data grid to query results
            Binding resultFeaturesBinding = new Binding("LastResult.Features");
            resultFeaturesBinding.Source = queryTask;
            QueryDetailsDataGrid.SetBinding(DataGrid.ItemsSourceProperty, resultFeaturesBinding);
            Query query = new ESRI.ArcGIS.Client.Tasks.Query();

            // Specify fields to return from query
            query.OutFields.AddRange(new string[] { "STATE_NAME", "SUB_REGION", "STATE_FIPS", "STATE_ABBR", "POP2000", "POP2007" });
            query.Geometry = args.Geometry;

            // Return geometry with result features
            query.ReturnGeometry = true;
            query.OutSpatialReference = MyMap.SpatialReference;

            queryTask.ExecuteAsync(query);
        }
        protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            if (arg.Button == MouseButtons.Left)
            {
                GeographicCoordinates geographicCoordinates = new GeographicCoordinates(ArcGlobe.Globe, arg.X, arg.Y);

                SpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceFactory((int)GeographicCoordinateSystem);

                PointGeometry pointGeometry = new PointGeometry(geographicCoordinates.Longitude, geographicCoordinates.Latitude, geographicCoordinates.AltitudeInKilometers, spatialReferenceFactory.SpatialReference);

                TextForm textForm = new TextForm();

                DialogResult dialogResult = textForm.ShowDialog();

                if (textForm.InputText.Length > 0)
                {
                    TextElement textElement = new TextElement(pointGeometry.Geometry, textForm.InputText, TextElementSize);

                    TableOfContents tableOfContents = new TableOfContents(ArcGlobe.Globe);

                    if (!tableOfContents.LayerExists(GraphicsLayerName))
                    {
                        tableOfContents.ConstructLayer(GraphicsLayerName);
                    }

                    Layer layer = new Layer(tableOfContents[GraphicsLayerName]);

                    layer.AddElement(textElement.Element, textElement.ElementProperties);

                    ArcGlobe.Globe.GlobeDisplay.RefreshViewers();
                }
            }
        }
        private void GeoprocessorTask_JobCompleted(object sender, ESRI.ArcGIS.Client.Tasks.JobInfoEventArgs e)
        {
            WaitGrid.Visibility = Visibility.Collapsed;

              if (e.JobInfo.JobStatus == esriJobStatus.esriJobSucceeded)
              {
            Geoprocessor geoprocessorTask = sender as Geoprocessor;

            System.Threading.Thread.Sleep(2000);

            resultLayer = geoprocessorTask.GetResultMapServiceLayer(e.JobInfo.JobId);
            resultLayer.InitializationFailed += new EventHandler<EventArgs>(resultLayer_InitializationFailed);
            resultLayer.DisplayName = e.JobInfo.JobId;
            if (resultLayer != null)
            {
              _displayViewshedInfo = true;
              MyMap.Layers.Add(resultLayer);
            }
              }
              else
              {
            MessageBox.Show("Geoprocessor service failed");
            _displayViewshedInfo = false;
              }
        }
Ejemplo n.º 27
0
        protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            int intx = arg.X;
            int inty = arg.Y;
            IPoint pPoints = new PointClass();
            pPoints.PutCoords(intx, inty);

            IActiveView activeView = ArcMap.Document.ActiveView;
            pPoints = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(-100, 40);//x,y为屏幕坐标

            ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay;
            ESRI.ArcGIS.Display.IDisplayTransformation displayTransformation = screenDisplay.DisplayTransformation;
            pPoints=displayTransformation.ToMapPoint(-120, 40);

            IMxDocument doc = ArcMap.Document;
            IMap map = doc.FocusMap;
            pPoints=doc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(-100, 40);

            AlterForm frm = null;
            if (frm == null || frm.IsDisposed)
                frm = new AlterForm(intx,inty);

            frm.Show();
            frm.TopMost = true;
            frm.Width = 400;
            frm.Height = 300;
            frm.Left = 500;
        }
        protected override void OnMouseUp(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            if (arg.Button == MouseButtons.Left)
            {
                GeographicCoordinates geographicCoordinates = new GeographicCoordinates(ArcGlobe.Globe, arg.X, arg.Y);

                SpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceFactory((int)GeographicCoordinateSystem);

                PointGeometry pointGeometry = new PointGeometry(geographicCoordinates.Longitude, geographicCoordinates.Latitude, geographicCoordinates.AltitudeInKilometers, spatialReferenceFactory.SpatialReference);

                IStyleGalleryItem styleGalleryItem = StyleGallerySelection.GetStyleGalleryItem();

                if (styleGalleryItem != null)
                {
                    StyleElement styleElement = new StyleElement(pointGeometry.Geometry, StyleElementSize, styleGalleryItem);

                    TableOfContents tableOfContents = new TableOfContents(ArcGlobe.Globe);

                    if (!tableOfContents.LayerExists(GraphicsLayerName))
                    {
                        tableOfContents.ConstructLayer(GraphicsLayerName);
                    }

                    Layer layer = new Layer(tableOfContents[GraphicsLayerName]);

                    layer.AddElement(styleElement.Element, styleElement.ElementProperties);

                    ArcGlobe.Globe.GlobeDisplay.RefreshViewers();
                }
            }
        }
Ejemplo n.º 29
0
    public void setupMap(ESRI.ArcGIS.ADF.Web.UI.WebControls.Map map1, int numLayers)
    {
        MapFunctionality mf = (MapFunctionality)map1.GetFunctionality(0);
        MapResourceLocal mrb = (MapResourceLocal)mf.MapResource;
        IServerContext mapContext = mrb.ServerContextInfo.ServerContext;
        IMapServerObjects mapServerObjects = (IMapServerObjects)mrb.MapServer;
        IMap map = mapServerObjects.get_Map(mrb.DataFrame);

        IEnumLayer layers = map.get_Layers(null, true);
        ILayer layer;
        StateSingleton.m_colors = new IColor[numLayers];
        StateSingleton.m_lines = new ILineSymbol[numLayers];
        IGeoFeatureLayer geoLayer;
        ISimpleRenderer renderer;
        IFillSymbol symbol;
        int i = 0;

        layer = layers.Next();
        while (i < numLayers){
                geoLayer = (IGeoFeatureLayer)layer;
                renderer = (ISimpleRenderer)geoLayer.Renderer;
                symbol = (IFillSymbol)renderer.Symbol;
                m_lines[i] = symbol.Outline;
                m_colors[i] = symbol.Color;
                i++;
                layer = layers.Next();
        }
    }
        private void setPixelData(int p, ESRI.ArcGIS.DataSourcesRaster.IPixelBlock3 pbIn, ESRI.ArcGIS.DataSourcesRaster.IPixelBlock3 pbInBig)
        {
            System.Array pbArr = (System.Array)pbIn.get_PixelData(p);
            for (int r = 0; r < pbIn.Height; r++)
            {
                for (int c = 0; c < pbIn.Width; c++)
                {
                    HashSet<float> hash = new HashSet<float>();
                    for (int rb = 0; rb < rws; rb++)
                    {
                        int nrb = r + rb;
                        for (int cb = 0; cb < clms; cb++)
                        {
                            int ncb = c + cb;
                            object objVl = pbInBig.GetVal(p, ncb, nrb);
                            if (objVl != null)
                            {
                                float vl = System.Convert.ToSingle(objVl);
                                hash.Add(vl);
                            }
                        }
                    }

                    pbArr.SetValue(hash.Count, c, r);
                }

            }
            pbIn.set_PixelData(p, pbArr);
        }