public override void Initialize()
{
if (!this.isInitializing && !base.IsInitialized)
{
#region 必设参数判断
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 (string.IsNullOrEmpty(this.MapServiceAddress))
{
base.Error = new ArgumentNullException(ExceptionStrings.ServiceAddressError);
base.Initialize();
return;
}
if (MapServicePort == int.MaxValue)
{
base.Error = new ArgumentNullException(ExceptionStrings.ServicePortIsNull);
base.Initialize();
return;
}
#endregion
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;
base.Initialize();
return;
}
this.isInitializing = true;
this.mapService = new SmMapService(this.Url.Trim(), this.MapName, this.MapServiceAddress, this.MapServicePort);
this.mapService.Initialized += new EventHandler<SmMapService.MapServiceInitalizeArgs>(mapService_Initialized);
this.mapService.Failed += new SmMapService.MapServiceFaultEventHandler(mapService_Fault);
this.mapService.Initialize();
}
}