当前位置: 首页>>代码示例>>C#>>正文


C# Graphic类代码示例

本文整理汇总了C#中Graphic的典型用法代码示例。如果您正苦于以下问题:C# Graphic类的具体用法?C# Graphic怎么用?C# Graphic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Graphic类属于命名空间,在下文中一共展示了Graphic类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoGeodesicLength

        private async Task DoGeodesicLength()
        {
            ResetButton.IsEnabled = false;

            try
            {
                if (mapView1.Editor.IsActive)
                    mapView1.Editor.Cancel.Execute(null);

                //Get the input polygon geometry from the user
                inputGeom = await mapView1.Editor.RequestShapeAsync(DrawShape.Polyline);

                if (inputGeom != null)
                {
                    //Add the polygon drawn by the user
                    var g = new Graphic
                    {
                        Geometry = inputGeom,
                    };
                    myGraphicsLayer.Graphics.Add(g);


                    //Get the label point for the input geometry
                    var length = GeometryEngine.GeodesicLength(inputGeom);
                    LineLengthTextBlock.Text = length.ToString("N2") + " m";
                    LineLengthTextBlock.Visibility = Windows.UI.Xaml.Visibility.Visible;
                }
            }
            catch (Exception)
            {

            }
            ResetButton.IsEnabled = true;

        }
开发者ID:KrisFoster44,项目名称:arcgis-runtime-samples-dotnet,代码行数:35,代码来源:LineLength.xaml.cs

示例2: UnionButton_Click

        // Unions feature geometries with a user defined polygon.
        private async void UnionButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                resultGraphics.Graphics.Clear();

                // wait for user to draw a polygon
                var poly = await mapView.Editor.RequestShapeAsync(DrawShape.Polygon);

                // get intersecting features from the feature layer
                SpatialQueryFilter filter = new SpatialQueryFilter();
                filter.Geometry = GeometryEngine.Project(poly, _statesLayer.FeatureTable.SpatialReference);
                filter.SpatialRelationship = SpatialRelationship.Intersects;
                filter.MaximumRows = 52;
                var stateFeatures = await _statesLayer.FeatureTable.QueryAsync(filter);

                // Union the feature geometries and add to graphics layer
                var states = stateFeatures.Select(feature => feature.Geometry);
                var sourcePolys = states.ToList();

				var unionPoly = GeometryEngine.Union(sourcePolys);
                var unionGraphic = new Graphic(unionPoly, _fillSymbol);

                resultGraphics.Graphics.Add(unionGraphic);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Union Error: " + ex.Message, "Union Sample");
            }
        }
开发者ID:rlwarford,项目名称:arcgis-runtime-samples-dotnet,代码行数:31,代码来源:UnionGeometry.xaml.cs

示例3: AddPolyLineGraphics

        private void AddPolyLineGraphics()
        {
            MapPoint ptStart = (MapPoint)graphicsLayer.Graphics[0].Geometry;
            MapPoint ptEnd = (MapPoint)graphicsLayer.Graphics[5].Geometry;

            // Solid Blue line above point graphics
            Graphic blueLine = new Graphic()
            {
                Symbol = new SimpleLineSymbol() { Color = Colors.Blue, Style = SimpleLineStyle.Solid, Width = 4 },
                Geometry = new Polyline(new CoordinateCollection() 
                { 
                    new Coordinate(ptStart.X, ptStart.Y + 1000000),
                    new Coordinate(ptEnd.X, ptEnd.Y + 1000000)
                })
            };

            // Dashed Green line below point graphics
            Graphic greenLine = new Graphic()
            {
                Symbol = new SimpleLineSymbol() { Color = Colors.Green, Style = SimpleLineStyle.Dash, Width = 4 },
                Geometry = new Polyline(new CoordinateCollection() 
                { 
                    new Coordinate(ptStart.X, ptStart.Y - 1000000),
                    new Coordinate(ptEnd.X, ptEnd.Y - 1000000)
                })
            };

            graphicsLayer.Graphics.Add(blueLine);
            graphicsLayer.Graphics.Add(greenLine);
        }
开发者ID:KrisFoster44,项目名称:arcgis-runtime-samples-dotnet,代码行数:30,代码来源:GraphicsLayerSample.xaml.cs

示例4: ParseFile

        private void ParseFile(string cached)
        {
            string[] sReferences = File.ReadAllLines(cached);
            foreach (string ap in sReferences)
            {
                try
                {
                    string[] s = ap.Split(',');
                    var g = new Graphic();
                    var pd = new ResourceDictionary();
                    pd.Source = new Uri("csGeoLayers;component/csGeoLayers/FlightTracker/FTDictionary.xaml", UriKind.Relative);
                    g.Symbol = pd["MediumMarkerSymbol"] as SimpleMarkerSymbol;

                    var mp = new MapPoint((float) Convert.ToDouble(s[7], CultureInfo.InvariantCulture),
                                          (float) Convert.ToDouble(s[6], CultureInfo.InvariantCulture),
                                          new SpatialReference(4326));

                    g.Geometry = mp;
                    Graphics.Add(g);
                }
                catch (Exception)
                {
                }
            }
            AppStateSettings.Instance.FinishDownload(_id);
        }
开发者ID:TNOCS,项目名称:csTouch,代码行数:26,代码来源:AirportLayer.cs

示例5: GasOverlayMats

 static GasOverlayMats()
 {
     TransmitterShader = ShaderDatabase.MetaOverlay;
     Graphic subGraphic = GraphicDatabase.Get<Graphic_Single>(TransmitterAtlasPath, TransmitterShader);
     LinkedOverlayGraphic = new Graphic_LinkedGasPipe(subGraphic);
     subGraphic.MatSingle.renderQueue = 3800;
 }
开发者ID:isistoy,项目名称:DevLib,代码行数:7,代码来源:GasNetGraphics.cs

示例6: Initialize

        private void Initialize()
        {
            // Create new Map with basemap
            Map myMap = new Map(Basemap.CreateImagery());

            // Create initial map location and reuse the location for graphic
            MapPoint centralLocation = new MapPoint(-226773, 6550477, SpatialReferences.WebMercator);
            Viewpoint initialViewpoint = new Viewpoint(centralLocation, 7500);

            // Set initial viewpoint
            myMap.InitialViewpoint = initialViewpoint;

            // Provide used Map to the MapView
            _myMapView.Map = myMap;

            // Create overlay to where graphics are shown
            GraphicsOverlay overlay = new GraphicsOverlay();

            // Add created overlay to the MapView
            _myMapView.GraphicsOverlays.Add(overlay);

            // Create a simple marker symbol
            SimpleMarkerSymbol simpleSymbol = new SimpleMarkerSymbol()
            {
                Color = Color.Red,
                Size = 10,
                Style = SimpleMarkerSymbolStyle.Circle
            };

            // Add a new graphic with a central point that was created earlier
            Graphic graphicWithSymbol = new Graphic(centralLocation, simpleSymbol);
            overlay.Graphics.Add(graphicWithSymbol);
        }
开发者ID:Esri,项目名称:arcgis-runtime-samples-dotnet,代码行数:33,代码来源:RenderSimpleMarkers.cs

示例7: WaitForFade

 private IEnumerator WaitForFade(Graphic g, float fadeInTime, float waitTime, float fadeOutTime, float waitAfter = 0)
 {
     yield return g.DOFade(1, fadeInTime).WaitForCompletion();
     yield return StartCoroutine(WaitOrSkip(waitTime));
     yield return g.DOFade(0, fadeOutTime).WaitForCompletion();
     yield return StartCoroutine(WaitOrSkip(waitAfter));
 }
开发者ID:steve-salmond,项目名称:LD33,代码行数:7,代码来源:IntroController.cs

示例8: MyMap_Tapped_1

        private async void MyMap_Tapped_1(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
        {
            var mp = MyMap.ScreenToMap(e.GetPosition(MyMap));
            Graphic g = new Graphic() { Geometry = mp };
            var graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
            graphicsLayer.Graphics.Add(g);

            var bufferResult = GeometryEngine.Buffer(mp, 100);
            var bufferLayer = MyMap.Layers["BufferLayer"] as GraphicsLayer;
            bufferLayer.Graphics.Add(new Graphic() { Geometry = bufferResult });


            var queryTask = new QueryTask(new Uri("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer/2"));
            var query = new ESRI.ArcGIS.Runtime.Tasks.Query()
            {
                ReturnGeometry = true,
                OutSpatialReference = MyMap.SpatialReference,
                Geometry = bufferResult
            };
            query.OutFields.Add("OWNERNME1");

            try
            {
                var queryResult = await queryTask.ExecuteAsync(query);
                if (queryResult != null && queryResult.FeatureSet != null)
                {
                    var resultLayer = MyMap.Layers["MyResultsGraphicsLayer"] as GraphicsLayer;
                    resultLayer.Graphics.AddRange(queryResult.FeatureSet.Features);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
开发者ID:jorik041,项目名称:arcgis-samples-winstore,代码行数:35,代码来源:QueryWithBuffer.xaml.cs

示例9: OnCreateGraphic

        protected override Graphic OnCreateGraphic(GraphicCollection cluster, MapPoint point, int maxClusterCount)
        {
            if (cluster.Count == 1) return cluster[0];

            double sum = 0;

            foreach (var g in cluster) {
                if (!g.Attributes.ContainsKey("Poi")) continue;
                try {
                    var poi = g.Attributes["Poi"] as PoI;
                    if (poi == null) continue;
                    if (poi.Labels.ContainsKey(AggregateLabel))
                        sum += Convert.ToDouble(poi.Labels[AggregateLabel]);
                }
                catch { }
            }
            //double size = (sum + 450) / 30;
            var size = (Math.Log(sum * SymbolScale / 10) * 10 + 20);
            if (size < 12) size = 12;
            var graphic = new Graphic
            {
                Symbol = new ClusterSymbol { Size = size },
                Geometry = point
            };
            graphic.Attributes.Add("Count", sum);
            graphic.Attributes.Add("Size", size);
            graphic.Attributes.Add("Color", InterpolateColor(size - 12, 100));
            return graphic;
        }
开发者ID:TNOCS,项目名称:csTouch,代码行数:29,代码来源:SumClusterer.cs

示例10: Draw

        public override void Draw(Graphic g)
        {
            var position = _c.Position * _c.Scale;
            var size = _c.Size * _c.Scale;

            g.DrawRectangle(position, size, true, Style.Background);
        }
开发者ID:hgrandry,项目名称:Mgx,代码行数:7,代码来源:BackgroundView.cs

示例11: CreateGeometries

		/// <summary>
		/// XAML creation of polygon and polyline geometries are currently not supported, so
		/// here they are created in code. Points are generated in the XAML for this sample.
		/// </summary>
		private void CreateGeometries()
		{
			var layer = mapView1.Map.Layers.OfType<GraphicsLayer>().First();
			int i = 0;
			foreach (var g in layer.Graphics)
				g.Attributes["Label"] = "Label #" + (++i).ToString();

			Polyline line = new Polyline(FromArray(-100,-30, -80,0, -60,-30, -40,0), SpatialReferences.Wgs84);
			var graphic = new Graphic(line, (Esri.ArcGISRuntime.Symbology.Symbol)Resources["OutlinedAndDashedSymbol"]);
			graphic.Attributes["Label"] = "OutlinedAndDashedSymbol";
			layer.Graphics.Add(graphic);

			Polygon polygon = new Polygon(FromArray(-30,-30, 0,-30, 0,0, -15,-10, -30,0, -30,-30), SpatialReferences.Wgs84);
			graphic = new Graphic(polygon, (Esri.ArcGISRuntime.Symbology.Symbol)Resources["VertexFillSymbol"]);
			graphic.Attributes["Label"] = "VertexFillSymbol";
			layer.Graphics.Add(graphic);

			//CIM symbols can only be created from JSON. The JSON is currently only constructed by publishing services to ArcGIS Server with advanced symbology
			string CIMSymbolJson = "{\"type\":\"CIMSymbolReference\",\"symbol\":{\"type\":\"CIMLineSymbol\",\"symbolLayers\":[{\"type\":\"CIMFilledStroke\",\"enable\":true,\"effects\":[{\"type\":\"CIMGeometricEffectArrow\",\"geometricEffectArrowType\":\"Block\",\"primitiveName\":null,\"width\":35}],\"capStyle\":\"Round\",\"pattern\":{\"type\":\"CIMSolidPattern\",\"color\":[0,0,0,255]},\"width\":2,\"lineStyle3D\":\"Strip\",\"alignment\":\"Center\",\"joinStyle\":\"Miter\",\"miterLimit\":10,\"patternFollowsStroke\":true}]},\"symbolName\":null}";
			var cimsymbol = Esri.ArcGISRuntime.Symbology.Symbol.FromJson(CIMSymbolJson);
			Polyline line2 = new Polyline(FromArray(20, -30, 30, 0, 50, -30, 70, 0), SpatialReferences.Wgs84);
			graphic = new Graphic(line2, cimsymbol);
			graphic.Attributes["Label"] = "CIM Symbol";
			layer.Graphics.Add(graphic);

			i = 0;
			foreach (var g in layer.Graphics)
			{
				g.Attributes["SymbolType"] = g.Symbol.GetType().Name;
				g.Attributes["ID"] = ++i;
			}
		}
开发者ID:KrisFoster44,项目名称:arcgis-runtime-samples-dotnet,代码行数:36,代码来源:SymbolsAndLabels.xaml.cs

示例12: MyDrawObject_DrawComplete

        private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args)
        {
            ESRI.ArcGIS.Client.Geometry.Polygon polygon = args.Geometry as ESRI.ArcGIS.Client.Geometry.Polygon;
            polygon.SpatialReference = MyMap.SpatialReference;
            Graphic graphic = new Graphic()
            {
                Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol,
                Geometry = polygon,
            };

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

            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
            graphicsLayer.Graphics.Add(graphic);

            List<Graphic> graphicList = new List<Graphic>();
            graphicList.Add(graphic);

            // Since there are multiple overloads for AreasAndLengthsAsync, make sure to use appropriate signature with correct parameter types.
            geometryService.AreasAndLengthsAsync(graphicList,null,null, (CalculationType)calculationTypeCombo.SelectedValue );

            // GeometryService.AreasAndLengths returns distances and areas in the units of the spatial reference.
            // The units in the map view's projection is decimal degrees.
            // Use the Project method to convert graphic points to a projection that uses a measured unit (e.g. meters).
            // If the map units are in measured units, the call to Project is unnecessary.
            // Important: Use a projection appropriate for your area of interest.
        }
开发者ID:ahthakore,项目名称:arcgis-samples-silverlight,代码行数:30,代码来源:AreasAndLengths.xaml.cs

示例13: myDrawObject_DrawComplete

        void myDrawObject_DrawComplete(object sender, DrawEventArgs e)
        {
            _geometryService.CancelAsync();
            _queryTask.CancelAsync();

            Graphic clickGraphic = new Graphic();
            clickGraphic.Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
            clickGraphic.Geometry = e.Geometry;
            // 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);
        }
开发者ID:jorik041,项目名称:arcgis-samples-winphone,代码行数:29,代码来源:BufferQuery.xaml.cs

示例14: FindAddressButton_Click

        private async void FindAddressButton_Click(object sender, RoutedEventArgs e)
        {
            OnlineLocatorTask locator = GetLocation();

            var findParams = new OnlineLocatorFindParameters(AddressTextBox.Text);
            findParams.OutSpatialReference = MyMapView.SpatialReference;
            findParams.SourceCountry = "US";

            var results = await locator.FindAsync(findParams, new System.Threading.CancellationToken());

            if (results.Count > 0)
            {
                var firstMatch = results[0].Feature;
                var matchLocation = firstMatch.Geometry as MapPoint;

                var matchSym = new PictureMarkerSymbol();
                var pictureURI = new Uri("http://static.arcgis.com/images/Symbols/Basic/GreenStickpin.png");
                await matchSym.SetSourceAsync(pictureURI);

                var matchGraphic = new Graphic(matchLocation, matchSym);

                var graphicsLayer = MyMap.Layers["GeocodeResults"] as GraphicsLayer;
                graphicsLayer.Graphics.Add(matchGraphic);

                var matchExtent = new Envelope(matchLocation.X - 100,
                                               matchLocation.Y - 100,
                                               matchLocation.X + 100,
                                               matchLocation.Y + 100);
                await MyMapView.SetViewAsync(matchExtent);
            }
        }
开发者ID:mattkingit,项目名称:MyArcGIS_DotNet,代码行数:31,代码来源:MainWindow.xaml.cs

示例15: StartButton_Click

		private async void StartButton_Click(object sender, RoutedEventArgs e)
		{
			SetupUI();

			// InstructionsTextBlock.Visibility = Windows.UI.Xaml.Visibility.Visible;
			StartButton.Visibility = Windows.UI.Xaml.Visibility.Collapsed;

			//Get the user's input
			densifyPolygonGeometry = (await MyMapView.Editor.RequestShapeAsync(DrawShape.Polygon)) as Polygon;

			//Create a graphic and add it to the PolygonGraphicsLayer
			var thePolygonGraphic = new Graphic
			{
				Geometry = densifyPolygonGeometry,
				Symbol = polygonSymbol
			};
			graphicsLayerPolygon.Graphics.Add(thePolygonGraphic);

			//show the vertices for the polygon
			foreach (var vert in densifyPolygonGeometry.Parts.FirstOrDefault().GetPoints())
			{
				var graphic = new Graphic { Geometry = new MapPoint(vert.X, vert.Y), Symbol = defaultVertexMarkerSymbol };
				graphicsLayerVertices.Graphics.Add(graphic);
			}

			DensifyPolygonsButton.IsEnabled = true;
		}
开发者ID:jordanparfitt,项目名称:arcgis-runtime-samples-dotnet,代码行数:27,代码来源:DensifyPolygons.xaml.cs


注:本文中的Graphic类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。