예제 #1
0
 private void btnReload_Click(object sender, EventArgs e)
 {
     _viewer.ClearSelection();
     MgResourceIdentifier mdfId = new MgResourceIdentifier("Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition");
     MgdMap map = new MgdMap(mdfId);
     MgDesktopMapViewerProvider provider = new MgDesktopMapViewerProvider(map);
     Shell.Instance.ReloadViewer(provider);
 }
예제 #2
0
파일: MainForm.cs 프로젝트: kanbang/Colt
        protected override void OnLoad(EventArgs e)
        {
            _wktRw = new MgWktReaderWriter();
            _geomFact = new MgGeometryFactory();
            new MapViewerController(mgMapViewer1,          //The MgMapViewer
                                    mgLegend1,             //The MgLegend
                                    this,                  //The IMapStatusBar
                                    mgPropertyPane1);      //The MgPropertyPane

            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);
            UpdateButtonCheckedState();
        }
예제 #3
0
파일: Program.cs 프로젝트: kanbang/Colt
        static void Main(string [] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            
            //Must call MgPlatform.Initialize() before we can work with anything from the MapGuide API
            try
            {
#if PROFILE
                using (new CallMeasure("MgdPlatform.Initialize"))
                {
                    MgdPlatform.Initialize("Platform.ini");
                }
#else
                MgdPlatform.Initialize("Platform.ini");
#endif
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error");
                return;
            }

            AppLayout layout = null;

            var ser = new XmlSerializer(typeof(AppLayout));
            if (args.Length == 1)
            {
                using (var file = File.OpenRead(args[0]))
                {
                    layout = (AppLayout)ser.Deserialize(file);
                }
            }/*
            else
            {
                layout = AppLayout.CreateDefault("MapGuide Desktop App Layout Example", "Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition");
                using (var file = File.OpenWrite("Sheboygan.AppLayout"))
                {
                    ser.Serialize(file, layout);
                }
            }*/

            var mdfId = new MgResourceIdentifier(layout.Map.MapDefinition);
            var provider = new MgDesktopMapViewerProvider(null);
            var resSvc = (MgResourceService)provider.CreateService(MgServiceType.ResourceService);
            if (resSvc.ResourceExists(mdfId))
            {
#if PROFILE
                using (new CallMeasure("MgdMap constructor (cold start)"))
                {
                    var mapCold = new MgdMap(mdfId);
                }
                MgdMap map = null;
                using (new CallMeasure("MgdMap constructor (warm start)"))
                {
                    map = new MgdMap(mdfId);
                }
                using (new CallMeasure("MgMapViewerProvider.LoadMap"))
                {
                    provider.LoadMap(map);
                }
#else
                provider.LoadMap(new MgdMap(mdfId));
#endif
            }
            var frm = Shell.Instance;
            ((Shell)frm).Initialize(layout, provider);
            Application.Run((Shell)frm);
            MgdPlatform.Terminate();
        }