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


C# LocationCollection.FirstOrDefault方法代码示例

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


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

示例1: DrawRoute

        /// <summary>
        /// 
        /// </summary>
        /// <param name="points"></param>
        private void DrawRoute(List<Location> points)
        {
            MapShapeLayer shapeLayer = new MapShapeLayer();
            MapPolyline polyline = new MapPolyline();

            LocationCollection lc = new LocationCollection();

            foreach (Location p in points)
            {
                lc.Add(p);
            }

            polyline.Locations = lc;
            polyline.Color = Color.FromArgb(255, 102, 0, 0);
            polyline.Width = 5;
            shapeLayer.Shapes.Add(polyline);
            Map.ShapeLayers.Clear();
            Map.ShapeLayers.Add(shapeLayer);

            Location midpoint = new Location(lc.FirstOrDefault().Latitude + ((lc.LastOrDefault().Latitude - lc.FirstOrDefault().Latitude) / 2.0),
                                             lc.FirstOrDefault().Longitude + ((lc.LastOrDefault().Longitude - lc.FirstOrDefault().Longitude) / 2.0));

            Map.SetView(midpoint, 15.5F);
        }
开发者ID:retrohacker,项目名称:SIUC311_Welling,代码行数:28,代码来源:MainPage.xaml.cs

示例2: Pushpin_Tap

        private void Pushpin_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            // Def Polyline:
            this.Polyline = new MapPolyline();
            this.Polyline.Stroke = new SolidColorBrush(Colors.Red); // stroke;
            this.Polyline.StrokeThickness = 5; // strokeThinkness;
            this.Polyline.Opacity = 0.7; // opacity;
            var pushpin = sender as Pushpin;
            var locationsList = new LocationCollection();
            List<GeoCoordinate> thisWayCoordinates = new List<GeoCoordinate>();
            GeoCoordinate routeLoc = pushpin.Location;
            if (routeLoc == LocationManager.GetCurrentLocation())
            {
            }
            else
            {
                RouteDesign routeDesign = this.ViewModel.NearbyRoutesCollection.Where(c => (c.Route.AllCoordinate[0] == pushpin.Location)).FirstOrDefault();
                if (routeDesign.Draw == false)
                {
                    thisWayCoordinates = routeDesign.Route.AllCoordinate;

                    foreach (GeoCoordinate coor in thisWayCoordinates)
                    {
                        locationsList.Add(coor);
                    }

                    Polyline.Locations = locationsList;
                    RouteBingMap.Children.Add(Polyline);
                    RouteBingMap.SetView(locationsList.FirstOrDefault(), 15);

                    // informations:
                    double wayDistance = 0;
                    for (int i = 0; i <= thisWayCoordinates.Count - 2; i++)
                    {
                        wayDistance += (thisWayCoordinates[i]).GetDistanceTo(thisWayCoordinates[i + 1]);
                    }

                    //ToolTipService.SetToolTip(pushpin, "The route length:" + wayDistance);

                    // RouteBingMap.Children.Add(pushpin);
                    ContextMenu contextMenu = ContextMenuService.GetContextMenu(pushpin);
                    //  contextMenu.DataContext = "llll";
                    contextMenu.DataContext = this.ViewModel.NearbyRoutesCollectionAndMe.Where(c => (c.Route.AllCoordinate[0] == pushpin.Location)).FirstOrDefault();
                    //RouteDesign r = (RouteDesign)(contextMenu.DataContext = this.ViewModel.NearbyRoutesCollectionAndMe.Where(c => (c.Route.AllCoordinate[0] == pushpin.Location)).FirstOrDefault());
                    if (contextMenu.Parent == null)
                    {
                        if (Open == "true")
                        {
                            Open = "false";
                            RouteView.Visibility = Visibility.Collapsed;
                        }
                        contextMenu.IsOpen = true;
                    }
                    // ToolTip t = new ToolTip();
                    //  t = (ToolTip)ToolTipService.GetToolTip(pushpin);
                    //// t.DataContext = this.ViewModel.NearbyRoutesCollectionAndMe.Where(c => (c.Route.AllCoordinate[0] == pushpin.Location)).FirstOrDefault();
                    // t.IsOpen = true;

                    // ToolTip t;
                    // t = new ToolTip();
                    //// t.Content = "The route length:" + wayDistance;
                    // t.FontSize = 20;
                    //  t.DataContext="ttttttttttttttttttttt"+(this.ViewModel.NearbyRoutesCollectionAndMe.Where(c => (c.Route.AllCoordinate[0] == pushpin.Location)).FirstOrDefault()).Route.WayDistance.ToString();
                    // t.FontSize = 20;
                    // t.IsOpen = true;
                    //  t.Visibility = Visibility.Visible;

                    //       MessageBox.Show("The route length:" + wayDistance);
                }
            }
        }
开发者ID:EranGon,项目名称:Lustig,代码行数:71,代码来源:MainPage.xaml.cs


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