Exemplo n.º 1
0
        protected override void ChangeMap()
        {
            if (base._map != null)
            {
                int i;
                if (int.TryParse(_hiddenServiceName.ToCharArray()[_hiddenServiceName.Length - 1].ToString(), out i))//if last char of _hiddenServiceName is int
                {
                    ServiceManager.DeleteService(_port, _hiddenServiceName);
                }
                else
                {
                    _hiddenServiceName = _hiddenServiceName + ServiceManager.PortEntities[_port].ServiceProvider.Services.Count(service => service.Key.Contains(_hiddenServiceName)).ToString();//INTERNALDOWNLOAD0,INTERNALDOWNLOAD1...
                }
                _pbsService = new PBSService(_hiddenServiceName, "", _port, SelectedDatasourceType, "", false, true, true, VisualStyle.None, null);

                ServiceManager.PortEntities[_port].ServiceProvider.Services.Add(_pbsService.ServiceName, _pbsService);
                _map.Layers.RemoveAt(0);
                BaiduTileLayer l = new BaiduTileLayer()
                {
                    baseUrl = _pbsService.UrlArcGIS
                };
                _map.Layers.Insert(0, l);
                Util.Envelope initial = _pbsService.DataSource.TilingScheme.InitialExtent;
                initalExtend = new ESRI.ArcGIS.Client.Geometry.Envelope(initial.XMin, initial.YMin, initial.XMax, initial.YMax);
            }
        }
Exemplo n.º 2
0
 protected override void ReadTilingScheme(out TilingScheme tilingScheme)
 {
     ReadBaiduTilingScheme(out tilingScheme);
     Util.Envelope initial      = tilingScheme.InitialExtent;
     Util.Point    pLeftTop     = Utility.GeographicToWebMercator(new Util.Point(initial.XMin, initial.YMax));
     Util.Point    pRightBottom = Utility.GeographicToWebMercator(new Util.Point(initial.XMax, initial.YMin));
     tilingScheme.InitialExtent = new Envelope(pLeftTop.X, pRightBottom.Y, pRightBottom.X, pLeftTop.Y);
     this.TilingScheme          = TilingSchemePostProcess(tilingScheme);
 }
        private void ProfileButtonClicked(object parameters)
        {
            string str = parameters.ToString();

            switch (str)
            {
            case "SAVE":
                if (DownloadExtent == null || Levels == null || Levels.Length == 0)
                {
                    MessageBox.Show(App.Current.FindResource("msgDownloadProfileInvalid").ToString(), App.Current.FindResource("msgError").ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                Util.Envelope env    = new Util.Envelope(DownloadExtent.XMin, DownloadExtent.YMin, DownloadExtent.XMax, DownloadExtent.YMax);
                string        result = _configManager.SaveDownloadProfileWithOverwrite(new PBS.DownloadProfile(SelectedProfile, Levels, env, _downloadPolygon));
                if (result != string.Empty)
                {
                    MessageBox.Show(result, App.Current.FindResource("msgError").ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                break;

            case "LOAD":
                DownloadProfile profile = _configManager.LoadDownloadProfile(SelectedProfile);
                if (profile == null)
                {
                    MessageBox.Show(App.Current.FindResource("msgLoadFailed").ToString(), App.Current.FindResource("msgError").ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                _downloadPolygon = profile.Polygon;
                Levels           = profile.Levels;
                DownloadExtent   = new Envelope(profile.Envelope.XMin, profile.Envelope.YMin, profile.Envelope.XMax, profile.Envelope.YMax);
                _graphicsLayer.ClearGraphics();
                _graphicsLayer.Graphics.Add(new Graphic()
                {
                    Symbol = new SimpleFillSymbol()
                    {
                        BorderBrush = new SolidColorBrush(Colors.Red),
                        Fill        = new SolidColorBrush(Color.FromArgb(100, 255, 0, 0))
                    },
                    Geometry = profile.Polygon == null ? _webMercator.FromGeographic(DownloadExtent) : AppUtility.ConvertPBSPolygonToEsriPolygon(profile.Polygon)
                });
                (CMDClickStartButton as DelegateCommand).RaiseCanExecuteChanged();
                TilesCount = AppUtility.CalculateTileCount(Levels, (Envelope)_webMercator.FromGeographic(DownloadExtent));
                break;

            case "DELETE":
                _configManager.DeleteDownloadProfile(SelectedProfile);
                break;

            default:
                break;
            }
            Profiles = new ObservableCollection <string>(_configManager.GetAllDownloadProfileNames());
        }