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


C# SceneView.LocationToScreen方法代码示例

本文整理汇总了C#中SceneView.LocationToScreen方法的典型用法代码示例。如果您正苦于以下问题:C# SceneView.LocationToScreen方法的具体用法?C# SceneView.LocationToScreen怎么用?C# SceneView.LocationToScreen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SceneView的用法示例。


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

示例1: EditPolylineAsync

        /// <summary>
        /// Edit existing <see cref="Polyline"/>. This will activate editing experience on the map. Edit is completed on double click.
        /// </summary>
        /// <param name="sceneView">The <see cref="SceneView"/> that is used for editing.</param>
        /// <exception cref="TaskCanceledException">If previous task wasn't completed, <see cref="TaskCanceledException"/>
        /// will be thrown. The task is cancelled if <see cref="Cancel"/> method or if any other draw or edit method is called.
        /// </exception>
        /// <returns>Return edited <see cref="Polygon"/> based on the user interactions.</returns>
        public static async Task<Polyline> EditPolylineAsync(SceneView sceneView, Polyline polyline)
		{
            Initialize();

			var tcs = new TaskCompletionSource<Polyline>();
			PolylineBuilder polylineBuilder = new PolylineBuilder(sceneView.SpatialReference);
			var sketchlayer = CreateSketchLayer(sceneView);
			var vertexlayer = CreateSketchLayer(sceneView);

			// Create vertices from the original polyline
			var vertices = new List<Graphic>();
			foreach (var vertex in (polyline.Parts[0].GetPoints()))
				vertices.Add(new Graphic(vertex, DefaultVertexSymbol));

			// Default to original polyline
			var newPolyline = new Polyline(polyline.Parts);

			Graphic lineGraphic = new Graphic(newPolyline) { Symbol = DefaultLineSymbol };
			Graphic lineMoveGraphic = new Graphic() { Symbol = DefaultLineMoveSymbol };

			sketchlayer.Graphics.AddRange(new Graphic[] { lineGraphic, lineMoveGraphic });
			vertexlayer.Graphics.AddRange(vertices);

			CancellationTokenSource tokenSource = null;
			Graphic selectedVertex = null;
			bool isEditingVertex = false;

			Action cleanupEvents = SetUpHandlers(sceneView,
				(p) => //On mouse move, move completion line around
				{
					if (p != null && isEditingVertex)
					{
						// Update visual indicator polyline
						var vertexPoints = newPolyline.Parts[0].GetPoints().ToList();
						var index = vertexPoints
							.IndexOf(vertexPoints.Where
								(point => GeometryEngine.Equals(point, selectedVertex.Geometry)).First());
						var temporaryVertices = new List<MapPoint>();

						if (index > 0)
							temporaryVertices.Add(vertexPoints[index - 1]); // Add previous segment
						temporaryVertices.Add(p);
						if (index != vertexPoints.Count() - 1)
							temporaryVertices.Add(vertexPoints[index + 1]); // Add next segment

						var builder = new PolylineBuilder(temporaryVertices);
						lineMoveGraphic.Geometry = builder.ToGeometry();
						lineMoveGraphic.IsVisible = true;
					}
				},
				async (p) => //On tap add a vertex
				{
					if (p == null) return;
					if (isEditingVertex) return;
					if (selectedVertex != null) selectedVertex.IsSelected = false;

					selectedVertex = await vertexlayer.HitTestAsync(sceneView, sceneView.LocationToScreen(p));

					// No vertex found so return
					if (selectedVertex == null)
						return;

					isEditingVertex = true;
					selectedVertex.IsSelected = true;
					tokenSource = new CancellationTokenSource();
					try
					{
						var newPoint = await SceneDrawHelper.DrawPointAsync(sceneView, tokenSource.Token);

						if (newPoint == null) return;
						
						var vertexPoints = newPolyline.Parts[0].GetPoints();
						var index = vertexPoints.ToList()
							.IndexOf(vertexPoints.Where
								(point => GeometryEngine.Equals(point, selectedVertex.Geometry)).First());
						var builder = new PolylineBuilder(vertexPoints);
						builder.Parts[0].MovePoint(index, newPoint);

						lineGraphic.Geometry = null;

						// Update polyline
						newPolyline = builder.ToGeometry();
						lineGraphic.Geometry = newPolyline;

						// Update vertex
						selectedVertex.Geometry = newPoint;
						tokenSource = null;
					}
					catch (TaskCanceledException tce)
					{
					}
					finally
//.........这里部分代码省略.........
开发者ID:Esri,项目名称:arcgis-runtime-demos-dotnet,代码行数:101,代码来源:SceneEditHelper.cs


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