Esempio n. 1
0
        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();
        }
Esempio n. 2
0
 static void Main()
 {
     MgdPlatform.Initialize("Platform.ini");
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new MainForm());
     MgdPlatform.Terminate();
 }
 private void OnAppExit(object sender, EventArgs e)
 {
     try
     {
         MgdPlatform.Terminate();
     }
     catch (MgException ex)
     {
         ex.Dispose();
     }
 }
Esempio n. 4
0
        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
            {
                var sw = new Stopwatch();
                sw.Start();
                MgdPlatform.Initialize("Platform.ini");
                sw.Stop();
                Trace.TraceInformation("Platform initialization took {0}ms", sw.ElapsedMilliseconds);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error");
                return;
            }

            //MgAppWindow is our Main Window class full of drag-and-drop component goodness. Go ahead and
            //take a look at MgAppWindow.cs source, not much code there except for the 3 generic invoke components and the
            //single custom selection handler. Everything else is encapsulated by designer-friendly drag and drop components
            //Most of the work is dragging and dropping components into the designer surface, and setting lots of properties
            var frm = new MgAppWindow();

            //We can initialize without specifying a map (allowing for components that do not
            //require a loaded map to still be used). You just have to call LoadMap() on the MgMapViewer
            //instance when ready (not demonstrated here). So if you do load a package here, you will
            //have to restart the application
            MgResourceIdentifier resId = null;

            if (args.Length == 1)
            {
                resId = new MgResourceIdentifier(args[0]);
                resId.Validate();
            }

            var    fact   = new MgdServiceFactory();
            var    resSvc = (MgdResourceService)fact.CreateService(MgServiceType.ResourceService);
            MgdMap map    = null;

            if (resId != null && resSvc.ResourceExists(resId))
            {
                map = new MgdMap(resId);
            }

            //This is just a pass-through call to MgMapViewer.Init()
            frm.LoadMap(new MgDesktopMapViewerProvider(map));

            Application.ApplicationExit += new EventHandler(OnAppExit);
            Application.Run(frm);
        }
Esempio n. 5
0
        static void Main()
        {
            var sw = new Stopwatch();

            sw.Start();
            MgdPlatform.Initialize("Platform.ini");
            sw.Stop();

            Trace.TraceInformation("Platform initialization took {0}ms", sw.ElapsedMilliseconds);

            Application.ApplicationExit += (s, e) =>
            {
                MgdPlatform.Terminate();
            };
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
Esempio n. 6
0
        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();
        }
Esempio n. 7
0
        public static void Main()
        {
            MgdPlatform.Initialize("Platform.ini");

            var resTest = new ResourceServiceTests();

            try
            {
                resTest.TestStart();

                Test(resTest.TestCase_ApplyResourcePackage);
                Test(resTest.TestCase_ResourceExists);
                //Test(resTest.TestCase_EnumerateResources);
                Test(resTest.TestCase_SetResource);
                Test(resTest.TestCase_MoveResource);
                Test(resTest.TestCase_CopyResource);
                Test(resTest.TestCase_GetResourceContent);
                Test(resTest.TestCase_GetResourceContents);
                Test(resTest.TestCase_GetResourceHeader);
                Test(resTest.TestCase_EnumerateReferences);
                Test(resTest.TestCase_ChangeResourceOwner);
                Test(resTest.TestCase_InheritPermissionsFrom);

                Test(resTest.TestCase_EnumerateResourceData);
                Test(resTest.TestCase_SetResourceData);
                Test(resTest.TestCase_RenameResourceData);
                Test(resTest.TestCase_GetResourceData);
                Test(resTest.TestCase_DeleteResourceData);

                Test(resTest.TestCase_DeleteResource);

                Test(resTest.TestCase_EnumerateUnmanagedData);
            }
            finally
            {
                resTest.TestEnd();
            }

            var featTest = new FeatureServiceTests();

            try
            {
                featTest.TestStart();

                Test(featTest.TestCase_GetFeatureProviders);
                Test(featTest.TestCase_TestConnectionSdfProvider);
                //Test(featTest.TestCase_TestFdoConnectionManager);
                Test(featTest.TestCase_GetConnectionPropertyValues);
                Test(featTest.TestCase_GetCapabilities);
                Test(featTest.TestCase_TestConnectionResourceIdentifier);
                Test(featTest.TestCase_GetSchemas);
                Test(featTest.TestCase_GetClasses);
                Test(featTest.TestCase_GetClassDefinition);
                Test(featTest.TestCase_DescribeSchema);
                Test(featTest.TestCase_ApplySchema);
                Test(featTest.TestCase_SelectFeatures);
                Test(featTest.TestCase_SelectAggregate);
                //    Test(featTest.TestCase_UpdateFeatures);
                //  TODO write test case when know how to make command collection
                Test(featTest.TestCase_ExecuteSqlQuery);
                Test(featTest.TestCase_ExecuteSqlNonQuery);
                Test(featTest.TestCase_GetSpatialContexts);
                Test(featTest.TestCase_GetLongTransactions);
                Test(featTest.TestCase_SetLongTransaction);
                //Test(featTest.TestCase_GetFeatures);
                //Test(featTest.TestCase_CloseFeatureReader);
                //Test(featTest.TestCase_GetSqlRows);
                //Test(featTest.TestCase_CloseSqlReader);
                //Test(featTest.TestCase_GetRaster);
                //Test(featTest.TestCase_GetDataRows);
                //Test(featTest.TestCase_CloseDataReader);
                //Test(featTest.TestCase_JoinFeatures);
                //Test(featTest.TestCase_JoinFeaturesChainedInner1ToMany);
                Test(featTest.TestCase_CreateFeatureSource);
                //Test(featTest.TestCase_BenchmarkSelectFeatures);
                //Test(featTest.TestCase_ConcurrentAccess);
            }
            finally
            {
                featTest.TestEnd();
            }

            var renTest = new RenderingServiceTests();

            try
            {
                renTest.TestStart();

                Test(renTest.TestCase_SymbologyPoints);
                Test(renTest.TestCase_SymbologyPointsParam);
                Test(renTest.TestCase_SymbologyLines);
                Test(renTest.TestCase_SymbologyLinesCrossTick);
                Test(renTest.TestCase_SymbologyPolygons);

                Test(renTest.TestCase_Annotation1);
                Test(renTest.TestCase_Annotation2);
                Test(renTest.TestCase_Annotation3);

                Test(renTest.TestCase_RenderDynamicOverlay);
                Test(renTest.TestCase_RenderMap);
                Test(renTest.TestCase_RenderMapWithWatermark);
                Test(renTest.TestCase_RenderLegend);
                //Test(renTest.TestCase_QueryFeatures);

                //Test(renTest.TestCase_RendererPerformance);
            }
            finally
            {
                renTest.TestEnd();
            }

            Console.WriteLine("\n{0} tests passed {1} tests failed", passed, failed);
            Trace.TraceInformation("{0} tests passed {1} tests failed", passed, failed);
        }
Esempio n. 8
0
 static void OnAppExit(object sender, EventArgs e)
 {
     MgdPlatform.Terminate();
 }