public override void Initialize( )
{
if (!this.isInitializing && !base.IsInitialized)
{
if (string.IsNullOrEmpty(this.Url))
{
base.Error = new ArgumentNullException(ExceptionStrings.InvalidUrl);
base.Initialize();
return;
}
if (string.IsNullOrEmpty(this.MapName))
{
base.Error = new ArgumentNullException(ExceptionStrings.MapNameIsNull);
base.Initialize();
return;
}
if (this.Scales == null)
{
base.Error = new ArgumentNullException(ExceptionStrings.ScalesIsNull);
base.Initialize();
return;
}
if (!Url.Contains("http://")) //相对地址
{
var pageUrl = System.Windows.Browser.HtmlPage.Document.DocumentUri;
var localUrl = pageUrl.AbsoluteUri.Substring(0 , pageUrl.AbsoluteUri.IndexOf(pageUrl.AbsolutePath));
Url = localUrl + Url;
}
if (IsSkipGetSMMapServiceInfo)
{
if (Bounds.IsEmpty)
{
Error = new ArgumentNullException("Bounds");
}
Dpi = ScaleHelper.GetSmDpi(ReferViewBounds , ReferViewer , ReferScale);
Dpi *= AdjustFactor;
this.isInitializing = true;
double[] resolutions = new double[Scales.Length];
for (int i = 0 ; i < Scales.Length ; i++)
{
resolutions[i] = ScaleHelper.ScaleConversion(Scales[i] , this.Dpi);
}
this.Resolutions = resolutions;
base.Initialize();
CreateUrl();
return;
}
this.isInitializing = true;
this.mapService = new SmMapService(this.Url.Trim() , this.MapName);
this.mapService.Initialized += new EventHandler<SmMapService.MapServiceInitalizeArgs>(mapService_Initialized);
this.mapService.Failed += new SmMapService.MapServiceFaultEventHandler(mapService_Failed);
this.mapService.Initialize();
CreateUrl();
}
}