public void configure(string servUrl, VRestore plug) { log(string.Format("VRestoreFromServ.configure...")); if (log == nullLog) { return; } try { log(string.Format("VRestoreFromServ.configure, SnapToLevels {0}", MapApplication.Current.Map.SnapToLevels)); if (servUrl == null) { ; } else { this.app = plug; serverURL = servUrl; log(string.Format("VRestoreFromServ.configure, stor.server url='{0}'", serverURL)); doRestoreMap(serverURL); } log(string.Format("VRestoreFromServ.configure done.")); } catch (Exception ex) { log(string.Format("VRestoreFromServ.configure, Initialization failed: {0}", ex.Message)); } } // public void configure()
} // void pingsrv_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) { /// <summary> /// If layers in config: clear map.layers; attach mapprogress event; add layers from config to map; /// set extent; set selected layer /// </summary> /// <param name="cfg"></param> /// <param name="map"></param> /// <param name="lyrInitFail"></param> /// <param name="mapProgress"></param> public static VLayer loadMapCfg(string cfg, ESRI.ArcGIS.Client.Map map, EventHandler <EventArgs> lyrInitFail, EventHandler <ProgressEventArgs> mapProgress) { // if LayersList: clean map; add layers from LayersList to map ESRI.ArcGIS.Client.Geometry.Envelope ext = VRestore.mapExtentFromConfig(cfg); var layersList = VRestore.lyrsListFromConfig(cfg); if (layersList.Count <= 0) { throw new Exception("VRestore.loadMapCfg: список слоев пуст, видимо была сохранена пустая карта"); } ESRI.ArcGIS.Client.LayerCollection lyrs = map.Layers; // clear map lyrs.Clear(); VLayer sl = null; if (mapProgress != null && layersList.Count > 0) { map.Progress -= mapProgress; map.Progress += mapProgress; } // add layers to map foreach (var x in layersList) { //string.Format("loadMapCfg, add layer {0}", x.lyrUrl).clog(); string.Format("VRestore.loadMapCfg, add layer '{0}' '{1}' '{2}'", x.ID, x.lyrName, x.lyrType).clog(); if (lyrInitFail != null) { x.lyr.InitializationFailed += new EventHandler <EventArgs>(lyrInitFail); } //x.lyr.SetValue(MapApplication.LayerNameProperty, x.lyrName); //x.lyr.Initialize(); lyrs.Add(x.lyr); MapApplication.SetLayerName(x.lyr, x.lyrName); if (x.selected) { sl = x; } } if (ext != null) { map.Extent = ext; } // select selected layer if (sl != null) { string.Format("VRestore.loadMapCfg, selected layer '{0}' '{1}'", sl.ID, sl.lyrName).clog(); MapApplication.Current.SelectedLayer = sl.lyr; } return(sl); } // public static VLayer loadMapCfg(string cfg, ESRI.ArcGIS.Client.Map map)
} // public void runTool(object param) private void cloneMap(ESRI.ArcGIS.Client.Map mapFrom, ESRI.ArcGIS.Client.Map mapTo) { log("VPrintImpl.cloneMap ..."); frmPrint.legend1.Map = null; var cfg = VSave.mapConfig(mapFrom); log(string.Format("cloneMap, mapCfg '{0}'", cfg)); mapTo.Layers.LayersInitialized -= onLayersInitialized; VRestore.loadMapCfg(cfg, mapTo, null, null); mapTo.Layers.LayersInitialized += onLayersInitialized; frmPrint.legend1.Map = mapTo; frmPrint.legend1.ShowOnlyVisibleLayers = true; PrintForm.legendFixed = false; // going to map update, need time to complete requests... //mapTo.ZoomToResolution(mapFrom.Resolution, mapFrom.Extent.GetCenter()); } // private void cloneMap(ESRI.ArcGIS.Client.Map mapFrom, ESRI.ArcGIS.Client.Map mapTo)