Пример #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();
        }
Пример #2
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();
        }
Пример #3
0
 protected override void SubInit()
 {
     _fact = new MgdServiceFactory();
     _resSvc = (MgdResourceService)_fact.CreateService(MgServiceType.ResourceService);
     _renderSvc = (MgdRenderingService)_fact.CreateService(MgServiceType.RenderingService);
     _mappingSvc = (MgdMappingService)_fact.CreateService(MgServiceType.MappingService);
 }
Пример #4
0
 protected override void SubInit()
 {
     _fact       = new MgdServiceFactory();
     _resSvc     = (MgdResourceService)_fact.CreateService(MgServiceType.ResourceService);
     _renderSvc  = (MgdRenderingService)_fact.CreateService(MgServiceType.RenderingService);
     _mappingSvc = (MgdMappingService)_fact.CreateService(MgServiceType.MappingService);
 }
Пример #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                MgFeatureService featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);

                MgByteReader response = featSvc.GetCapabilities(txtFdoProvider.Text);
                new XmlResponseDialog(response).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Пример #6
0
        public void TestCase_GetResourceContents()
        {
            try
            {
                var fact    = new MgdServiceFactory();
                var service = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);

                //Try to get the content using NULL arguments
                Assert.Throws <MgNullArgumentException>(() => service.GetResourceContents(null, null));

                //Try to get the content of a resource that doesn't exist
                MgStringCollection resourceNotExistCol = new MgStringCollection();
                resourceNotExistCol.Add(resourceNotExist.ToString());
                resourceNotExistCol.Add(resourceIdentifier.ToString());
                Assert.Throws <MgResourceNotFoundException>(() => service.GetResourceContents(resourceNotExistCol, null));

                //Get the content of the resource that was added in TestCase_SetResource
                MgStringCollection resIds = new MgStringCollection();
                resIds.Add(resourceIdentifier.ToString());
                resIds.Add(resourceIdentifier4.ToString());
                var ret = service.GetResourceContents(resIds, null);
                Assert.AreEqual(2, ret.GetCount());

                for (int i = 0; i < ret.GetCount(); i++)
                {
                    Assert.False(string.IsNullOrEmpty(ret.GetItem(i)));
                }
            }
            catch (MgException ex)
            {
                Assert.Fail(ex.Message);
                ex.Dispose();
            }
        }
Пример #7
0
        public void TestCase_GetResourceContent()
        {
            try
            {
                var fact    = new MgdServiceFactory();
                var service = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);

                //Try to get the content using NULL arguments
                Assert.Throws <MgNullArgumentException>(() => service.GetResourceContent(null));

                //Try to get the content of a resource that doesn't exist
                Assert.Throws <MgResourceNotFoundException>(() => service.GetResourceContent(resourceNotExist));

                //Get the content of the resource that was added in TestCase_SetResource
                var byteReader = service.GetResourceContent(resourceIdentifier);
                var mimeType   = byteReader.GetMimeType();
                Assert.True(mimeType.Equals(MgMimeType.Xml));

                string xml = byteReader.ToString();
                Assert.True(xml.Length > 0);
                Assert.True(xml.Contains("<FeatureSource"));
                Assert.True(xml.EndsWith("</FeatureSource>"));
            }
            catch (MgException ex)
            {
                Assert.Fail(ex.Message);
                ex.Dispose();
            }
        }
Пример #8
0
        public void TestCase_CopyResource()
        {
            try
            {
                var fact    = new MgdServiceFactory();
                var service = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);

                //Try to use NULL arguments
                Assert.Throws <MgNullArgumentException>(() => service.CopyResource(null, null, true));
                Assert.Throws <MgNullArgumentException>(() => service.CopyResource(resourceIdentifier, null, true));
                Assert.Throws <MgNullArgumentException>(() => service.CopyResource(null, resourceIdentifier2, true));

                //Try to use source & destination as the same thing
                Assert.Throws <MgInvalidArgumentException>(() => service.CopyResource(resourceIdentifier2, resourceIdentifier2, false));

                //Copy the moved resource to another location
                service.CopyResource(resourceIdentifier, resourceIdentifier2, false);

                //Try to copy a resource to one that should now exist
                Assert.Throws <MgDuplicateResourceException>(() => service.CopyResource(resourceIdentifier2, resourceIdentifier, false));
            }
            catch (MgException ex)
            {
                Assert.Fail(ex.Message);
                ex.Dispose();
            }
        }
Пример #9
0
        // public void TestCase_EnumerateResources() {}

        public void TestCase_SetResource()
        {
            try
            {
                var fact    = new MgdServiceFactory();
                var service = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);

                //Try to use NULL arguments
                Assert.Throws <MgNullArgumentException>(() => service.SetResource(null, null, null));
                Assert.Throws <MgNullArgumentException>(() => service.SetResource(resourceIdentifier, null, null));

                //Add a new resource
                MgByteSource source = new MgByteSource(resourceContentFileName);
                MgByteReader reader = source.GetReader();
                service.SetResource(resourceIdentifier, reader, null);

                //Try to add the same resource again (should be fine and just update it)
                source = new MgByteSource(resourceContentFileName);
                reader = source.GetReader();
                service.SetResource(resourceIdentifier, reader, null);

                //Add another resource layer definition, which references to the feature source. This is for cascade MoveResource test.
                source = new MgByteSource(resourceContentFileName2);
                reader = source.GetReader();
                service.SetResource(resourceIdentifier4, reader, null);
            }
            catch (MgException ex)
            {
                Assert.Fail(ex.Message);
                ex.Dispose();
            }
        }
Пример #10
0
        private void btnCreateFile_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                var featureSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
                var param = new MgFileFeatureSourceParams();
                param.CoordinateSystemWkt = txtCoordinateSystemWkt.Text;
                param.FileName = txtFileName.Text;

                var schemas = featureSvc.XmlToSchema(File.ReadAllText(txtSchemaXml.Text));
                param.FeatureSchema = schemas.GetItem(0);

                param.ProviderName = txtProvider.Text;
                param.SpatialContextDescription = "Created from MgFileFeatureSourceParams";
                param.SpatialContextName = txtCoordinateSystemName.Text;
                param.XYTolerance = double.Parse(txtXYTolerance.Text);
                param.ZTolerance = double.Parse(txtZTolerance.Text);

                var fsId = new MgResourceIdentifier(txtResourceId.Text);

                featureSvc.CreateFeatureSource(fsId, param);
                MessageBox.Show("Success");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Пример #11
0
        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();
            }
        }
Пример #12
0
        public void TestCase_RenameResourceData()
        {
            try
            {
                var fact    = new MgdServiceFactory();
                var service = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);

                Assert.Throws <MgNullArgumentException>(() => service.RenameResourceData(null, resourceDataName, resourceDataName2, true));
                Assert.Throws <MgResourceNotFoundException>(() => service.RenameResourceData(resourceNotExist, resourceDataName, resourceDataName2, true));
                Assert.Throws <MgResourceDataNotFoundException>(() => service.RenameResourceData(resourceIdentifier, "DoesNotExist", resourceDataName2, true));
                Assert.Throws <MgNullArgumentException>(() => service.RenameResourceData(resourceIdentifier, resourceDataName, "", true));

                service.RenameResourceData(resourceIdentifier, resourceDataName, resourceDataName2, false);
                var    reader = service.EnumerateResourceData(resourceIdentifier);
                string xml    = reader.ToString();
                Assert.True(xml.Contains("<Name>" + resourceDataName2 + "</Name>"));
                Assert.False(xml.Contains("<Name>" + resourceDataName + "</Name>"));

                service.RenameResourceData(resourceIdentifier, resourceDataName2, resourceDataName, false);
                reader = service.EnumerateResourceData(resourceIdentifier);
                xml    = reader.ToString();
                Assert.True(xml.Contains("<Name>" + resourceDataName + "</Name>"));
                Assert.False(xml.Contains("<Name>" + resourceDataName2 + "</Name>"));
            }
            catch (MgException ex)
            {
                Assert.Fail(ex.Message);
                ex.Dispose();
            }
        }
Пример #13
0
        public void TestCase_SetResourceData()
        {
            try
            {
                var fact    = new MgdServiceFactory();
                var service = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);

                Assert.Throws <MgNullArgumentException>(() => service.SetResourceData(null, "", "", null));

                var dataSource = new MgByteSource(dataFileName);
                var dataReader = dataSource.GetReader();

                Assert.Throws <MgNullArgumentException>(() => service.SetResourceData(resourceIdentifier, "", "File", dataReader));

                dataSource = new MgByteSource(dataFileName);
                dataReader = dataSource.GetReader();
                service.SetResourceData(resourceIdentifier, resourceDataName, "File", dataReader);

                var    reader = service.EnumerateResourceData(resourceIdentifier);
                string xml    = reader.ToString();

                Assert.True(xml.Contains("<Name>" + resourceDataName + "</Name>"));
            }
            catch (MgException ex)
            {
                Assert.Fail(ex.Message);
                ex.Dispose();
            }
        }
Пример #14
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgdRenderingService renSvc = (MgdRenderingService)fact.CreateService(MgServiceType.RenderingService);

                MgResourceIdentifier mdfId = new MgResourceIdentifier(txtMapDefinition.Text);
                var sw = new Stopwatch();
                sw.Start();
                MgdMap map = new MgdMap(mdfId);
                sw.Stop();
                Trace.TraceInformation("Runtime map created in {0}ms", sw.ElapsedMilliseconds);

                map.SetViewScale(Convert.ToDouble(txtScale.Text));
                sw.Reset();
                sw.Start();
                MgByteReader response = renSvc.RenderTile(map, txtBaseGroup.Text, Convert.ToInt32(txtCol.Text), Convert.ToInt32(txtRow.Text));
                sw.Stop();
                Trace.TraceInformation("RenderTile executed in {0}ms", sw.ElapsedMilliseconds);
                new ImageResponseDialog(response).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error");
            }
        }
Пример #15
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgdRenderingService renSvc = (MgdRenderingService)fact.CreateService(MgServiceType.RenderingService);

                MgResourceIdentifier mdfId = new MgResourceIdentifier(txtMapDefinition.Text);
                var sw = new Stopwatch();
                sw.Start();
                MgdMap map = new MgdMap(mdfId);
                sw.Stop();
                Trace.TraceInformation("Runtime map created in {0}ms", sw.ElapsedMilliseconds);

                map.SetViewScale(Convert.ToDouble(txtScale.Text));
                sw.Reset();
                sw.Start();
                MgByteReader response = renSvc.RenderTile(map, txtBaseGroup.Text, Convert.ToInt32(txtCol.Text), Convert.ToInt32(txtRow.Text));
                sw.Stop();
                Trace.TraceInformation("RenderTile executed in {0}ms", sw.ElapsedMilliseconds);
                new ImageResponseDialog(response).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error");
            }
        }
Пример #16
0
        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();
            }
        }
        public LocalGetResourceContents(LocalConnection conn)
        {
            this.Parent = conn;
            var fact = new MgdServiceFactory();

            _resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
        }
Пример #18
0
        private void btnCreateFile_Click(object sender, EventArgs e)
        {
            try
            {
                var fact       = new MgdServiceFactory();
                var featureSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
                var param      = new MgFileFeatureSourceParams();
                param.CoordinateSystemWkt = txtCoordinateSystemWkt.Text;
                param.FileName            = txtFileName.Text;

                var schemas = featureSvc.XmlToSchema(File.ReadAllText(txtSchemaXml.Text));
                param.FeatureSchema = schemas.GetItem(0);

                param.ProviderName = txtProvider.Text;
                param.SpatialContextDescription = "Created from MgFileFeatureSourceParams";
                param.SpatialContextName        = txtCoordinateSystemName.Text;
                param.XYTolerance = double.Parse(txtXYTolerance.Text);
                param.ZTolerance  = double.Parse(txtZTolerance.Text);

                var fsId = new MgResourceIdentifier(txtResourceId.Text);

                featureSvc.CreateFeatureSource(fsId, param);
                MessageBox.Show("Success");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Пример #19
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgFeatureService featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
                MgFeatureQueryOptions query = new MgFeatureQueryOptions();
                string[] propNames = txtProps.Text.Split(',');
                foreach (var p in propNames)
                {
                    if (string.IsNullOrEmpty(p))
                        continue;

                    query.AddFeatureProperty(p);
                }

                foreach (Pair p in lstComputed.Items)
                {
                    query.AddComputedProperty(p.Name, p.Expr);
                }

                if (!string.IsNullOrEmpty(txtFilter.Text.Trim()))
                    query.SetFilter(txtFilter.Text.Trim());

                MgResourceIdentifier fsId = new MgResourceIdentifier(txtFeatureSource.Text);

                MgFeatureReader reader = featSvc.SelectFeatures(fsId, txtClass.Text, query);
                new ReaderResponseDialog(reader).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Пример #20
0
        public override void Run()
        {
            var fact = new MgdServiceFactory();
            MgdFeatureService featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);

            MgByteReader br = featSvc.QueryCacheInfo();
            new ConnectionPoolStatusDialog(br).ShowDialog();
        }
Пример #21
0
        public override void Run()
        {
            var fact = new MgdServiceFactory();
            MgdFeatureService featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);

            MgByteReader br = featSvc.QueryCacheInfo();

            new ConnectionPoolStatusDialog(br).ShowDialog();
        }
Пример #22
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);
        }
Пример #23
0
        public void TestCase_DeleteResource()
        {
            try
            {
                var fact    = new MgdServiceFactory();
                var service = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
                var featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);

                Assert.Throws <MgNullArgumentException>(() => service.DeleteResource(null));

                service.DeleteResource(resourceNotExist);

                service.DeleteResource(resourceIdentifier);
                service.DeleteResource(resourceIdentifier2);
                service.DeleteResource(resourceIdentifier3);

                var resource = new MgResourceIdentifier("Library://UnitTests/Data/TEST.FeatureSource");

                var source = new MgByteSource("..\\UnitTestFiles\\TEST.FeatureSource");
                var reader = source.GetReader();
                service.SetResource(resource, reader, null);

                var dataSource = new MgByteSource("..\\UnitTestFiles\\TEST.sdf");
                var dataReader = dataSource.GetReader();
                service.SetResourceData(resource, "TEST.sdf", "File", dataReader);

                MgFeatureAggregateOptions agg = new MgFeatureAggregateOptions();
                agg.AddFeatureProperty("Data");

                var mgdr = featSvc.SelectAggregate(resource, "TEST", agg);
                Assert.True(mgdr.ReadNext());
                mgdr.Close();

                service.DeleteResource(resource);
            }
            catch (MgException ex)
            {
                Assert.Fail(ex.Message);
                ex.Dispose();
            }
        }
Пример #24
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);
        }
Пример #25
0
 private void btnCreate_Click(object sender, EventArgs e)
 {
     try
     {
         var fact       = new MgdServiceFactory();
         var featureSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
         featureSvc.RegisterProvider(txtProviderPath.Text);
         MessageBox.Show("Success");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Пример #26
0
 public void TestCase_ChangeResourceOwner()
 {
     try
     {
         var fact    = new MgdServiceFactory();
         var service = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
         Assert.Throws <MgNotImplementedException>(() => service.ChangeResourceOwner(null, "", false));
     }
     catch (MgException ex)
     {
         Assert.Fail(ex.Message);
         ex.Dispose();
     }
 }
Пример #27
0
 private void btnCreate_Click(object sender, EventArgs e)
 {
     try
     {
         var fact = new MgdServiceFactory();
         var featureSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
         featureSvc.RegisterProvider(txtProviderPath.Text);
         MessageBox.Show("Success");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Пример #28
0
 public void TestCase_EnumerateUnmanagedData()
 {
     try
     {
         var fact    = new MgdServiceFactory();
         var service = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
         Assert.Throws <MgNotImplementedException>(() => service.EnumerateUnmanagedData("", true, "", ""));
     }
     catch (MgException ex)
     {
         Assert.Fail(ex.Message);
         ex.Dispose();
     }
 }
Пример #29
0
 private void btnExecute_Click(object sender, EventArgs e)
 {
     try
     {
         var fact       = new MgdServiceFactory();
         var featureSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
         var response   = featureSvc.GetSchemaMapping(txtProvider.Text, txtConnString.Text);
         new XmlResponseDialog(response).ShowDialog();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Пример #30
0
 private void btnExecute_Click(object sender, EventArgs e)
 {
     try
     {
         var fact = new MgdServiceFactory();
         var featureSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
         var response = featureSvc.GetSchemaMapping(txtProvider.Text, txtConnString.Text);
         new XmlResponseDialog(response).ShowDialog();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Пример #31
0
 public void TestCase_InheritPermissionsFrom()
 {
     try
     {
         var fact    = new MgdServiceFactory();
         var service = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
         Assert.Throws <MgNotImplementedException>(() => service.InheritPermissionsFrom(null));
     }
     catch (MgException ex)
     {
         Assert.Fail(ex.Message);
         ex.Dispose();
     }
 }
Пример #32
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                MgdServiceFactory fact   = new MgdServiceFactory();
                MgResourceService resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);

                MgByteReader response = resSvc.EnumerateUnmanagedData(txtPath.Text, chkRecursive.Checked, txtType.Text, txtFilter.Text);
                new XmlResponseDialog(response).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Пример #33
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgFeatureService featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);

                MgByteReader response = featSvc.EnumerateDataStores(textBox1.Text, textBox2.Text);
                new XmlResponseDialog(response).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Пример #34
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgFeatureService featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);

                bool res = featSvc.TestConnection(txtFdoProvider.Text, txtConnectionString.Text);
                MessageBox.Show("Result: " + res);
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Пример #35
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgFeatureService featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);

                MgByteReader response = featSvc.EnumerateDataStores(textBox1.Text, textBox2.Text);
                new XmlResponseDialog(response).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Пример #36
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                MgdServiceFactory fact = new MgdServiceFactory();
                MgResourceService resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);

                MgByteReader response = resSvc.EnumerateUnmanagedData(txtPath.Text, chkRecursive.Checked, txtType.Text, txtFilter.Text);
                new XmlResponseDialog(response).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Пример #37
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgFeatureService featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);

                bool res = featSvc.TestConnection(txtFdoProvider.Text, txtConnectionString.Text);
                MessageBox.Show("Result: " + res);
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Пример #38
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgResourceService resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);

                MgResourceIdentifier resId = new MgResourceIdentifier(textBox1.Text);
                bool exists = resSvc.ResourceExists(resId);
                MessageBox.Show("Exists: " + exists);
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Пример #39
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgResourceService    resSvc   = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
                MgResourceIdentifier resId    = new MgResourceIdentifier(textBox1.Text);
                MgByteReader         response = resSvc.EnumerateResourceData(resId);

                new XmlResponseDialog(response).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Пример #40
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgFeatureService featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
                MgResourceIdentifier fsId = new MgResourceIdentifier(textBox1.Text);
                MgSpatialContextReader response = featSvc.GetSpatialContexts(fsId, checkBox1.Checked);

                new SpatialContextResultDialog(response).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Пример #41
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgFeatureService       featSvc  = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
                MgResourceIdentifier   fsId     = new MgResourceIdentifier(textBox1.Text);
                MgSpatialContextReader response = featSvc.GetSpatialContexts(fsId, checkBox1.Checked);

                new SpatialContextResultDialog(response).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Пример #42
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgResourceService    resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
                MgResourceIdentifier resId  = new MgResourceIdentifier(textBox1.Text);
                resSvc.DeleteResourceData(resId, textBox2.Text);

                MessageBox.Show("Success");
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Пример #43
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgResourceService resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
                MgResourceIdentifier resId = new MgResourceIdentifier(textBox1.Text);
                MgByteReader response = resSvc.EnumerateResourceData(resId);

                new XmlResponseDialog(response).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Пример #44
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgResourceService resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
                MgResourceIdentifier resId = new MgResourceIdentifier(textBox1.Text);
                resSvc.DeleteResourceData(resId, textBox2.Text);

                MessageBox.Show("Success");
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Пример #45
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgResourceService resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);

                MgResourceIdentifier resId = new MgResourceIdentifier(textBox1.Text);
                bool exists = resSvc.ResourceExists(resId);
                MessageBox.Show("Exists: " + exists);
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Пример #46
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         var fact = new MgdServiceFactory();
         MgResourceService resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
         MgResourceIdentifier resId = new MgResourceIdentifier(txtResourceId.Text);
         string type = txtType.Text;
         int depth = Convert.ToInt32(txtDepth.Text);
         MgByteReader response = resSvc.EnumerateResources(resId, depth, type);
         new XmlResponseDialog(response).ShowDialog();
     }
     catch (MgException ex)
     {
         MessageBox.Show(ex.ToString(), "Error from MapGuide");
     }
 }
Пример #47
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         var fact = new MgdServiceFactory();
         MgResourceService    resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
         MgResourceIdentifier resId  = new MgResourceIdentifier(txtResourceId.Text);
         string       type           = txtType.Text;
         int          depth          = Convert.ToInt32(txtDepth.Text);
         MgByteReader response       = resSvc.EnumerateResources(resId, depth, type);
         new XmlResponseDialog(response).ShowDialog();
     }
     catch (MgException ex)
     {
         MessageBox.Show(ex.ToString(), "Error from MapGuide");
     }
 }
Пример #48
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgFeatureService featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
                MgResourceIdentifier fsId = new MgResourceIdentifier(textBox1.Text);
                string sql = textBox2.Text;

                MgSqlDataReader reader = featSvc.ExecuteSqlQuery(fsId, sql);
                new ReaderResponseDialog(reader).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Пример #49
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgFeatureService featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
                MgResourceIdentifier resId = new MgResourceIdentifier(textBox1.Text);
                string sql = textBox2.Text;

                int res = featSvc.ExecuteSqlNonQuery(resId, sql);
                MessageBox.Show(res + " results affected");
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Пример #50
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgFeatureService     featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
                MgResourceIdentifier resId   = new MgResourceIdentifier(textBox1.Text);
                string sql = textBox2.Text;

                int res = featSvc.ExecuteSqlNonQuery(resId, sql);
                MessageBox.Show(res + " results affected");
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Пример #51
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgdRenderingService renSvc = (MgdRenderingService)fact.CreateService(MgServiceType.RenderingService);
                MgResourceIdentifier resId = new MgResourceIdentifier(textBox1.Text);

                MgdMap map = new MgdMap(resId);

                double x;
                double y;
                if (double.TryParse(textBox2.Text, out x) &&
                    double.TryParse(textBox3.Text, out y))
                {
                    map.SetViewCenterXY(x, y);
                }

                int w;
                int h;
                if (int.TryParse(txtWidth.Text, out w) &&
                    int.TryParse(txtHeight.Text, out h))
                {
                    map.SetDisplaySize(w, h);
                }

                double scale;
                if (double.TryParse(textBox4.Text, out scale))
                {
                    map.SetViewScale(scale);
                }

                var sw = new Stopwatch();
                sw.Start();
                MgByteReader response = renSvc.RenderMap(map, null, textBox5.Text);
                sw.Stop();
                Trace.TraceInformation("RenderMap executed in {0}ms", sw.ElapsedMilliseconds);

                new ImageResponseDialog(response).ShowDialog();
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Пример #52
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgResourceService resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
                MgResourceIdentifier source = new MgResourceIdentifier(textBox1.Text);
                MgResourceIdentifier target = new MgResourceIdentifier(textBox2.Text);

                resSvc.CopyResource(source, target, checkBox1.Checked);

                MessageBox.Show("Success");
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Пример #53
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgResourceService resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);

                MgByteSource source = new MgByteSource(textBox1.Text);
                MgByteReader reader = source.GetReader();

                resSvc.ApplyResourcePackage(reader);

                MessageBox.Show("Success");
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Пример #54
0
        private void btnCreateRdbms_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                var featureSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
                var param = new MgdRdbmsFeatureSourceParams();
                param.CoordinateSystemWkt = txtCoordinateSystemWkt.Text;

                param.Service = txtService.Text;
                param.DataStore = txtDataStore.Text;
                param.Username = txtUsername.Text;
                param.Password = txtPassword.Text;

                var schemas = featureSvc.XmlToSchema(File.ReadAllText(txtSchemaXml.Text));
                param.FeatureSchema = schemas.GetItem(0);

                param.ProviderName = txtProvider.Text;
                param.SpatialContextDescription = "Created from MgFileFeatureSourceParams";
                param.SpatialContextName = txtCoordinateSystemName.Text;
                param.XYTolerance = double.Parse(txtXYTolerance.Text);
                param.ZTolerance = double.Parse(txtZTolerance.Text);

                string[] tokens = txtExtents.Text.Split(',').Select(x => x.Trim()).ToArray();
                MgEnvelope env = new MgEnvelope(
                    double.Parse(tokens[0]),
                    double.Parse(tokens[1]),
                    double.Parse(tokens[2]),
                    double.Parse(tokens[3]));

                param.SpatialContextExtents = env;
                

                var fsId = new MgResourceIdentifier(txtResourceId.Text);

                featureSvc.CreateFeatureSource(fsId, param);
                MessageBox.Show("Success");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Пример #55
0
        public void TestCase_ApplyResourcePackage()
        {
            try
            {
                var fact = new MgdServiceFactory();
                var service = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
                Assert.Throws<MgNullArgumentException>(() => service.ApplyResourcePackage(null));

                MgByteSource source = new MgByteSource(packageName);
                source.SetMimeType(MgMimeType.Binary);
                MgByteReader reader = source.GetReader();

                service.ApplyResourcePackage(reader);
            }
            catch (MgException ex)
            {
                Assert.Fail(ex.Message);
                ex.Dispose();
            }
        }
Пример #56
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgResourceService resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
                MgResourceIdentifier resId = new MgResourceIdentifier(textBox1.Text);
                string dataName = textBox2.Text;
                MgByteSource source = new MgByteSource(textBox3.Text);
                MgByteReader reader = source.GetReader();

                resSvc.SetResourceData(resId, dataName, "File", reader);

                MessageBox.Show("Success");
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Пример #57
0
        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();
        }
Пример #58
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgResourceService resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
                MgResourceIdentifier resId = new MgResourceIdentifier(textBox1.Text);
                MgByteReader response = resSvc.GetResourceData(resId, textBox2.Text);

                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    MgByteSink sink = new MgByteSink(response);
                    sink.ToFile(saveFileDialog1.FileName);
                    MessageBox.Show("Saved to: " + saveFileDialog1.FileName);
                }
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }
Пример #59
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            try
            {
                var resId = new MgResourceIdentifier(txtResourceId.Text);
                resId.Validate();

                var fact = new MgdServiceFactory();
                var resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService);
                if (!resSvc.ResourceExists(resId))
                {
                    MessageBox.Show("The specified resource does not exist");
                    return;
                }
                this.ResourceID = resId;
                this.DialogResult = DialogResult.OK;
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.Message);
                ex.Dispose();
            }
        }
Пример #60
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                var fact = new MgdServiceFactory();
                MgFeatureService featSvc = (MgdFeatureService)fact.CreateService(MgServiceType.FeatureService);
                MgResourceIdentifier fsId = new MgResourceIdentifier(txtFeatureSource.Text);

                MgStringCollection schemas = featSvc.GetSchemas(fsId);
                string[] values = new string[schemas.GetCount()];

                for (int i = 0; i < schemas.GetCount(); i++)
                {
                    values[i] = schemas.GetItem(i);
                }

                MessageBox.Show(string.Join(Environment.NewLine, values), "Schemas found");
            }
            catch (MgException ex)
            {
                MessageBox.Show(ex.ToString(), "Error from MapGuide");
            }
        }