示例#1
0
        /// <summary>
        /// The on comboBox selection change event.
        /// </summary>
        /// <param name="item">The newly selected combo box item</param>
        protected override void OnSelectionChange(ComboBoxItem item)
        {
            if (item == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(item.Text))
            {
                return;
            }

            string        name          = item.Text;
            List <Mosaic> filteredItems = ItemsClean.Where(i => i.name == name).ToList();
            Mosaic        mosaic        = filteredItems.First();

            if (Module1.Current.IsTrial)
            {
                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Basemaps cannot be added to the TOC using trial accounts");
            }
            else
            {
                OpenWebMapAsync(mosaic);
            }
            SelectedItem = null;
            // TODO  Code behavior when selection changes.
        }
        private void SetThumbnail(Mosaic item)
        {
            TilePointConvert tilePointConvert = new TilePointConvert();
            var      extent = MapView.Active.Extent;
            int      z      = 7;
            MapPoint sw     = MapPointBuilder.CreateMapPoint(extent.XMin, extent.YMin, extent.SpatialReference);

            sw = GeometryEngine.Instance.Project(sw, SpatialReferences.WGS84) as MapPoint;
            MapPoint ne = MapPointBuilder.CreateMapPoint(extent.XMax, extent.YMax, SpatialReferences.WGS84);

            ne = GeometryEngine.Instance.Project(ne, SpatialReferences.WGS84) as MapPoint;
            IList <MapPoint> mapPoints = new List <MapPoint>();

            mapPoints.Add(sw);
            mapPoints.Add(ne);
            double zz = TilePointConvert.BestMapView(mapPoints, 100, 56, 2);

            z = (int)Math.Floor(zz);
            if (z < 0)
            {
                z = z * -1;
            }
            var    centerProjected = GeometryEngine.Instance.Project(extent.Center, SpatialReferences.WGS84) as MapPoint;
            double centerlong      = centerProjected.X;
            double centerlat       = centerProjected.Y;
            PointF point           = tilePointConvert.WorldToTilePos(centerlong, centerlat, z);

            item.Thumbnail = item._links.tiles.Replace("{x}", Math.Floor(point.X).ToString()).Replace("{y}", Math.Floor(point.Y).ToString()).Replace("{z}", z.ToString());
        }