static void Main(string[] args) { MgdPlatform.Initialize("Platform.ini"); string currentDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); //Test mapguide-api-base MgCoordinateSystemFactory csFact = new MgCoordinateSystemFactory(); Console.WriteLine("Testing coordinate system categories"); MgStringCollection csCategories = csFact.EnumerateCategories(); for (int i = 0; i < csCategories.GetCount(); i++) { Console.WriteLine(csCategories.GetItem(i)); } //Test mg-desktop MgdServiceFactory serviceFact = new MgdServiceFactory(); Console.Write("Can we create a MgdFeatureService? "); MgdFeatureService featSvc = (MgdFeatureService)serviceFact.CreateService(MgServiceType.FeatureService); Console.WriteLine("yes"); Console.Write("Can we create a MgdResourceService? "); MgdResourceService resSvc = (MgdResourceService)serviceFact.CreateService(MgServiceType.ResourceService); Console.WriteLine("yes"); MgdPlatform.Terminate(); Console.WriteLine("Things look all good :) Press any key to continue"); Console.Read(); }
public void TestEnd() { try { var fact = new MgdServiceFactory(); MgdResourceService service = (MgdResourceService)fact.CreateService(MgServiceType.ResourceService); MgResourceIdentifier mapres1 = new MgResourceIdentifier("Library://UnitTests/Data/Shuttle.DrawingSource"); service.DeleteResource(mapres1); if (service.ResourceExists(resourceIdentifier)) { service.DeleteResource(resourceIdentifier); } if (service.ResourceExists(resourceIdentifier2)) { service.DeleteResource(resourceIdentifier2); } if (service.ResourceExists(resourceIdentifier3)) { service.DeleteResource(resourceIdentifier3); } if (service.ResourceExists(resourceIdentifier4)) { service.DeleteResource(resourceIdentifier4); } } catch (MgException ex) { ex.Dispose(); } }
protected override void OnLoad(EventArgs e) { mgMapViewer1.UseRenderMapIfTiledLayersExist = true; mgMapViewer1.RespectFiniteDisplayScales = true; new MapViewerController(mgMapViewer1, //The MgMapViewer mgLegend1, //The MgLegend this, //The IMapStatusBar mgPropertyPane1, //The MgPropertyPane mgDefaultToolbar1); //The MgDefaultToolbar MgdServiceFactory factory = new MgdServiceFactory(); MgdResourceService resSvc = (MgdResourceService)factory.CreateService(MgServiceType.ResourceService); MgResourceIdentifier mapDefId = new MgResourceIdentifier("Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition"); //If this map definition doesn't exist, we ask the user to //load the Sheboygan package if (!resSvc.ResourceExists(mapDefId)) { using (OpenFileDialog diag = new OpenFileDialog()) { diag.Filter = "MapGuide Packages (*.mgp)|*.mgp"; if (diag.ShowDialog() == DialogResult.OK) { MgByteSource source = new MgByteSource(diag.FileName); MgByteReader reader = source.GetReader(); resSvc.ApplyResourcePackage(reader); } else { //No map, nothing to do here Application.Exit(); } } } //Create our runtime map MgdMap map = new MgdMap(mapDefId); //Create our viewer provider MgMapViewerProvider provider = new MgDesktopMapViewerProvider(map); //Initialize our viewer with this provider mgMapViewer1.Init(provider); }
public override void Dispose() { if (_resSvc != null) { _resSvc.Dispose(); _resSvc = null; } if (_featSvc != null) { _featSvc.Dispose(); _featSvc = null; } if (_drawSvc != null) { _drawSvc.Dispose(); _drawSvc = null; } if (_renderSvc != null) { _renderSvc.Dispose(); _renderSvc = null; } if (_tileSvc != null) { _tileSvc.Dispose(); _tileSvc = null; } }
private MgdResourceService GetResourceService() { if (_resSvc == null) _resSvc = (MgdResourceService)_fact.CreateService(MgServiceType.ResourceService); return _resSvc; }