public UploadToGoogleMapsEngine(ref GoogleMapsEngineToolsExtensionForArcGIS ext)
        {
            // initialize and configure log4net, reading from Xml .config file
            log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config"));

            log.Info("OAuth2AuthForm initializing.");

            // initialize the local extension object
            log.Debug("Initializing the reference to the Extension.");
            this.ext = ext;

            // initialize form components
            InitializeComponent();

            // establish a reference to the running ArcMap instance
            ESRI.ArcGIS.ArcMapUI.IMxDocument mxDoc = (ESRI.ArcGIS.ArcMapUI.IMxDocument)ArcMap.Application.Document;

            // retrieve a reference to the selected layer
            ESRI.ArcGIS.Carto.ILayer selectedLayer = mxDoc.SelectedLayer;

            // determine if the selected layer is valid
            if (!Tools.ToolsCommand_UploadToGoogleMapsEngine.isLayerValid(selectedLayer))
            {
                // Handle invalid layer
                System.Windows.Forms.MessageBox.Show("The selected layer does not meet the minimum requirements or is invalid.");

                // close the dialog
                this.Close();
            }
            else
            {
                this.isLayerValidated = true;
            }
        }
        protected override void OnClick()
        {
            try
            {
                // establish a reference to the running ArcMap instance
                ESRI.ArcGIS.ArcMapUI.IMxDocument mxDoc
                    = (ESRI.ArcGIS.ArcMapUI.IMxDocument)ArcMap.Application.Document;

                // retrieve the TOC selected layer (if there is one)
                ESRI.ArcGIS.Carto.ILayer selectedLayer = mxDoc.SelectedLayer;

                // validate layer meets minmum requirements
                if (isLayerValid(selectedLayer))
                {
                    // open the upload dialog
                    Dialogs.Interact.UploadToGoogleMapsEngine dialog
                        = new Dialogs.Interact.UploadToGoogleMapsEngine(ref ext);
                    dialog.Show();
                }
                else
                {
                    // display an error to the user
                    System.Windows.Forms.MessageBox.Show("Please select a valid vector or raster layer.");
                }
            }
            catch (System.Exception ex)
            {
                // log an error, unable to open in dialog
                log.Error(ex);
            }
        }
Example #3
0
        private static IFeatureLayer IsFeatureLayerInGroupLayer(string sSource, IGroupLayer pGrpLyr)
        {
            if (pGrpLyr == null)
            {
                return(null);
            }

            ESRI.ArcGIS.ArcMapUI.IMxDocument pMXDoc = ArcMap.Document;
            IMap            pMap           = pMXDoc.FocusMap;
            ICompositeLayer compositeLayer = pGrpLyr as ICompositeLayer;

            if (compositeLayer != null & compositeLayer.Count > 0)
            {
                for (int i = 0; i <= compositeLayer.Count - 1; i++)
                {
                    if (compositeLayer.Layer[i] is IFeatureLayer)
                    {
                        ESRI.ArcGIS.Geodatabase.IDataset pLayer = (ESRI.ArcGIS.Geodatabase.IDataset)compositeLayer.Layer[i];
                        string pLayerPath = Path.Combine(pLayer.Workspace.PathName, pLayer.BrowseName + ".shp");
                        if (string.Compare(pLayerPath, sSource, true) == 0)
                        {
                            return((IFeatureLayer)pLayer);
                        }
                    }
                }
            }

            return(null);
        }
Example #4
0
        private void UploadToGoogleMapsEngine_Load(object sender, EventArgs e)
        {
            // establish a reference to the running ArcMap instance
            ESRI.ArcGIS.ArcMapUI.IMxDocument mxDoc = (ESRI.ArcGIS.ArcMapUI.IMxDocument)ArcMap.Application.Document;

            // retrieve a reference to the selected layer
            ESRI.ArcGIS.Carto.ILayer selectedLayer = mxDoc.SelectedLayer;

            // get the data layer of this feature layer
            ESRI.ArcGIS.Carto.IDataLayer2 dataLayer
                = (ESRI.ArcGIS.Carto.IDataLayer2)selectedLayer;
            ESRI.ArcGIS.Geodatabase.IDatasetName datasetName
                = (ESRI.ArcGIS.Geodatabase.IDatasetName)dataLayer.DataSourceName;

            // add a script manager to the browser
            // in order to capture select events
            webBrowser.ObjectForScripting = new BrowerScriptManager(this);

            // fetch the upload_dialog_html resource
            log.Debug("fetch the upload_dialog_html resource");
            string uploadhtml = Properties.Resources.upload_dialog_html;

            // populate the source dataset information
            uploadhtml = uploadhtml.Replace("{sourcename}", datasetName.Name);
            uploadhtml = uploadhtml.Replace("{sourceworkspace}", datasetName.WorkspaceName.PathName);

            // configure raster/vector specific information
            if (selectedLayer is ESRI.ArcGIS.Carto.IFeatureLayer)
            {
                // cast the selected layer into a feature layer
                ESRI.ArcGIS.Carto.IFeatureLayer featureLayer
                    = (ESRI.ArcGIS.Carto.IFeatureLayer)selectedLayer;

                // set the source vector type
                uploadhtml = uploadhtml.Replace("{sourcetype}", featureLayer.DataSourceType);

                // set the variable upload type to vector
                uploadType = "vector";
            }
            else if (selectedLayer is ESRI.ArcGIS.Carto.IRasterLayer)
            {
                // cast the selected layer into a raster layer
                ESRI.ArcGIS.Carto.IRasterLayer rasterLayer
                    = (ESRI.ArcGIS.Carto.IRasterLayer)selectedLayer;

                // set the source raster type
                uploadhtml = uploadhtml.Replace("{sourcetype}", "Raster: "
                                                + rasterLayer.RowCount + " rows, " + rasterLayer.ColumnCount + " columns, "
                                                + rasterLayer.BandCount + " bands");

                // set the variable upload type to raster
                uploadType = "raster";
            }

            // set the upload html
            log.Debug("Setting the HTML to the web browser on the dialog.");
            this.webBrowser.DocumentText = uploadhtml;
        }
Example #5
0
        // ArcGIS Snippet Title:
        // Get Map from ArcMap
        //
        // Long Description:
        // Get Map from ArcMap.
        //
        // Add the following references to the project:
        // ESRI.ArcGIS.ArcMapUI
        // ESRI.ArcGIS.Carto
        // ESRI.ArcGIS.Framework
        // ESRI.ArcGIS.System
        //
        // Intended ArcGIS Products for this snippet:
        // ArcGIS Desktop (ArcEditor, ArcInfo, ArcView)
        //
        // Applicable ArcGIS Product Versions:
        // 9.2
        // 9.3
        // 9.3.1
        // 10.0
        //
        // Required ArcGIS Extensions:
        // (NONE)
        //
        // Notes:
        // This snippet is intended to be inserted at the base level of a Class.
        // It is not intended to be nested within an existing Method.
        //

        ///<summary>Get Map from ArcMap</summary>
        ///
        ///<param name="application">An IApplication interface that is the ArcMap application.</param>
        ///
        ///<returns>An IMap interface.</returns>
        ///
        ///<remarks></remarks>
        public static ESRI.ArcGIS.Carto.IMap GetMap(ESRI.ArcGIS.Framework.IApplication application)
        {
            if (application == null)
            {
                return(null);
            }
            ESRI.ArcGIS.ArcMapUI.IMxDocument mxDocument = ((ESRI.ArcGIS.ArcMapUI.IMxDocument)(application.Document)); // Explicit Cast
            ESRI.ArcGIS.Carto.IActiveView    activeView = mxDocument.ActiveView;
            ESRI.ArcGIS.Carto.IMap           map        = activeView.FocusMap;

            return(map);
        }
Example #6
0
        private void zoomFromDataGrid(string sWhere)
        {
            //Set the query filter. use the arguements passed into the function
            IQueryFilter pQueryFilter = new QueryFilterClass();

            pQueryFilter.WhereClause = sWhere;

            ESRI.ArcGIS.ArcMapUI.IMxDocument pMxDoc = (ESRI.ArcGIS.ArcMapUI.IMxDocument) this.App.Document;
            IMap pMap = (IMap)pMxDoc.FocusMap;

            IFeatureLayer pTaxlotLayer;

            using (CSpatialSubs oSpatialSubs = new CSpatialSubs())
            {
                pTaxlotLayer = (IFeatureLayer)oSpatialSubs.returnFeatureLayer(pMap, SConst.Taxlots);
                oSpatialSubs.selectFeatures(pQueryFilter, this.App, pTaxlotLayer, true);
            }
        }
Example #7
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspaceFactory.OpenFromFile(gdbPath, 0);
            // Create a FeatureLayer and assign a shapefile to it.
            IFeatureLayer featureLayer = new FeatureLayer();

            string fcName = fcList.Items[fcList.SelectedIndex].ToString();

            featureLayer.FeatureClass = featureWorkspace.OpenFeatureClass(fcName);
            ILayer layer = (ILayer)featureLayer;

            layer.Name = featureLayer.FeatureClass.AliasName;


            ESRI.ArcGIS.ArcMapUI.IMxDocument mxDocument = (ESRI.ArcGIS.ArcMapUI.IMxDocument)
                                                              (ArcMap.Application.Document);
            IMap map = mxDocument.FocusMap;

            map.AddLayer(layer);
        }
        public void GenerateXmlData(string diagramName, string diagramClassName, ref object xmlSource, ref bool cancel)
        {
            MSXML2.DOMDocument      xmlDOMDocument = new MSXML2.DOMDocument();
            ESRI.ArcGIS.Carto.IMaps maps;
            ESRI.ArcGIS.Carto.IMap  currentMap;
            ESRI.ArcGIS.Geodatabase.IEnumFeature enumFeature;
            ESRI.ArcGIS.Geodatabase.IFeature     feature;
            MSXML2.IXMLDOMProcessingInstruction  xmlProcInstr;
            MSXML2.IXMLDOMElement   xmlDiagrams;
            MSXML2.IXMLDOMElement   xmlDiagram;
            MSXML2.IXMLDOMElement   xmlFeatures;
            MSXML2.IXMLDOMElement   xmlDataSources;
            MSXML2.IXMLDOMElement   xmlDataSource;
            MSXML2.IXMLDOMElement   xmlDataSource_Namestring;
            MSXML2.IXMLDOMElement   xmlDataSource_WorkspaceInfo;
            MSXML2.IXMLDOMElement   xmlWorkspaceInfo_PathName;
            MSXML2.IXMLDOMElement   xmlWorkspaceInfo_WorkspaceFactoryProgID;
            MSXML2.IXMLDOMAttribute rootAtt1;
            MSXML2.IXMLDOMAttribute rootAtt2;
            ESRI.ArcGIS.Geodatabase.IEnumFeatureSetup enumFeatureSetup;
            string xmlDatabase;

            // Retrieving the selected set of features
            enumFeature = null;
            feature     = null;

            m_mxDocument = (ESRI.ArcGIS.ArcMapUI.IMxDocument)m_application.Document;
            maps         = m_mxDocument.Maps;
            int i = 0;

            while (i < maps.Count)
            {
                currentMap                 = maps.get_Item(i);
                enumFeature                = (ESRI.ArcGIS.Geodatabase.IEnumFeature)currentMap.FeatureSelection;
                enumFeatureSetup           = (ESRI.ArcGIS.Geodatabase.IEnumFeatureSetup)enumFeature;
                enumFeatureSetup.AllFields = true;
                feature = enumFeature.Next();
                if (feature != null)
                {
                    break;
                }

                i += 1;
            }

            // if (there is no selected feature in the MxDocument, the procedure is interrupted
            if (feature == null)
            {
                MessageBox.Show("There is no feature selected. Select a set of features.", "Generate/Update XML diagrams", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                cancel = true;
                return;
            }

            //Checking the feature dataset related to the selected features
            ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass;
            string featureDatasetName;

            featureClass       = (ESRI.ArcGIS.Geodatabase.IFeatureClass)feature.Class;
            featureDatasetName = featureClass.FeatureDataset.BrowseName;
            xmlDatabase        = featureClass.FeatureDataset.Workspace.PathName;

            // if the selected features come from another feature dataset than the expected one, the procedure is interrupted
            if (featureDatasetName != DatasetName)
            {
                //More restrictive condition: if (xmlDatabase != "c:\Mybase.gdb" )
                MessageBox.Show("This component doesn't work from the selected set of features.");
                cancel = true;
                return;
            }

            // Writing the XML heading items in the DOMDocument
            xmlProcInstr = xmlDOMDocument.createProcessingInstruction("xml", "version='1.0'");
            xmlDOMDocument.appendChild(xmlProcInstr);
            xmlProcInstr = null;

            //-------- Diagrams Section START --------
            // Creating the root Diagrams element
            xmlDiagrams = xmlDOMDocument.createElement("Diagrams");
            xmlDOMDocument.documentElement = xmlDiagrams;
            rootAtt1      = xmlDOMDocument.createAttribute("xmlns:xsi");
            rootAtt1.text = "http://www.w3.org/2001/XMLSchema-instance";
            xmlDiagrams.attributes.setNamedItem(rootAtt1);

            // Creating the Diagram element for the diagram which is going to be generated
            xmlDiagram = xmlDOMDocument.createElement("Diagram");
            xmlDiagrams.appendChild(xmlDiagram);
            rootAtt1      = xmlDOMDocument.createAttribute("EnforceDiagramTemplateName");
            rootAtt1.text = "false";
            xmlDiagram.attributes.setNamedItem(rootAtt1);
            rootAtt2      = xmlDOMDocument.createAttribute("EnforceDiagramName");
            rootAtt2.text = "false";
            xmlDiagram.attributes.setNamedItem(rootAtt2);

            //-------- DataSources Section START --------
            // Creating the DataSources element
            xmlDataSources = xmlDOMDocument.createElement("Datasources");
            xmlDiagram.appendChild(xmlDataSources);
            xmlDataSource = xmlDOMDocument.createElement("Datasource");
            xmlDataSources.appendChild(xmlDataSource);

            // Specifying the Namestring for the related Datasource element
            xmlDataSource_Namestring = xmlDOMDocument.createElement("NameString");
            xmlDataSource.appendChild(xmlDataSource_Namestring);
            xmlDataSource_Namestring.nodeTypedValue = "XMLDataSource";

            // Specifying the WorkspaceInfo for the related Datasource element
            xmlDataSource_WorkspaceInfo = xmlDOMDocument.createElement("WorkSpaceInfo");
            xmlDataSource.appendChild(xmlDataSource_WorkspaceInfo);
            xmlWorkspaceInfo_PathName = xmlDOMDocument.createElement("PathName");
            xmlDataSource_WorkspaceInfo.appendChild(xmlWorkspaceInfo_PathName);
            xmlWorkspaceInfo_PathName.nodeTypedValue = xmlDatabase;
            xmlWorkspaceInfo_WorkspaceFactoryProgID  = xmlDOMDocument.createElement("WorkspaceFactoryProgID");
            xmlDataSource_WorkspaceInfo.appendChild(xmlWorkspaceInfo_WorkspaceFactoryProgID);
            xmlWorkspaceInfo_WorkspaceFactoryProgID.nodeTypedValue = "esriDataSourcesGDB.FileGDBWorkspaceFactory";
            //-------- DataSources Section END --------

            //-------- Features Section START --------
            xmlFeatures = xmlDOMDocument.createElement("Features");
            xmlDiagram.appendChild(xmlFeatures);
            while (feature != null)
            {
                switch (feature.FeatureType)
                {
                case ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimpleJunction:
                    CreateXMLNodeElt(feature, ref xmlDOMDocument, ref xmlFeatures, feature.Class.AliasName);
                    break;

                case ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimpleEdge:
                    CreateXMLLinkElt(feature, ref xmlDOMDocument, ref xmlFeatures, feature.Class.AliasName);
                    break;
                }
                feature = enumFeature.Next();
            }

            // output the XML we created
            xmlSource = xmlDOMDocument;
            cancel    = false;
            //-------- Features Section END --------
            //-------- Diagrams Section END --------
        }
        protected void uploadButtonClicked(String projectId, String name, String description, String tags, String aclName, String attribution)
        {
            try
            {
                // create a new Processing Dialog
                Dialogs.Processing.ProgressDialog processingDialog = new Processing.ProgressDialog();

                // check to see if the layer is valid
                // and destination is configured correctly
                if (isLayerValidated &&
                    projectId != null && projectId.Length > 0 &&
                    name != null && name.Length > 0 &&
                    aclName != null && aclName.Length > 0)
                {
                    // show the processing dialog
                    processingDialog.Show();

                    // create a reference to the Google Maps Engine API
                    MapsEngine.API.GoogleMapsEngineAPI api = new MapsEngine.API.GoogleMapsEngineAPI(ref log);

                    // establish a reference to the running ArcMap instance
                    ESRI.ArcGIS.ArcMapUI.IMxDocument mxDoc = (ESRI.ArcGIS.ArcMapUI.IMxDocument)ArcMap.Application.Document;

                    // retrieve a reference to the selected layer
                    ESRI.ArcGIS.Carto.ILayer selectedLayer = mxDoc.SelectedLayer;

                    // create a temporary working directory
                    System.IO.DirectoryInfo tempDir
                        = System.IO.Directory.CreateDirectory(ext.getLocalWorkspaceDirectory() + "\\" + System.Guid.NewGuid());

                    // determine what type of layer is selected
                    if (selectedLayer is ESRI.ArcGIS.Carto.IFeatureLayer)
                    {
                        // export a copy of the feature class to a "uploadable" Shapefile
                        // raise a processing notification
                        ext.publishRaiseDownloadProgressChangeEvent(false, "Extracting a copy of '" + selectedLayer.Name + "' (feature class) for data upload.");
                        ExportLayerToShapefile(tempDir.FullName, selectedLayer.Name, selectedLayer);

                        processingDialog.Update();
                        processingDialog.Focus();

                        // create a list of files in the temp directory
                        List <String> filesNames = new List <String>();
                        for (int k = 0; k < tempDir.GetFiles().Count(); k++)
                        {
                            if (!tempDir.GetFiles()[k].Name.EndsWith(".lock"))
                            {
                                filesNames.Add(tempDir.GetFiles()[k].Name);
                            }
                        }

                        // create a Google Maps Engine asset record
                        ext.publishRaiseDownloadProgressChangeEvent(false, "Requesting a new Google Maps Engine asset be created.");
                        MapsEngine.DataModel.gme.UploadingAsset uploadingAsset
                            = api.createVectorTableAssetForUploading(ext.getToken(),
                                                                     MapsEngine.API.GoogleMapsEngineAPI.AssetType.table,
                                                                     projectId,
                                                                     name,
                                                                     aclName,
                                                                     filesNames,
                                                                     description,
                                                                     tags.Split(",".ToCharArray()).ToList <String>(),
                                                                     "UTF-8");

                        // Initiate upload of file(s)
                        ext.publishRaiseDownloadProgressChangeEvent(false, "Starting to upload files...");
                        api.uploadFilesToAsset(ext.getToken(), uploadingAsset.id, tempDir.GetFiles());

                        // launch a web browser
                        ext.publishRaiseDownloadProgressChangeEvent(false, "Launching a web browser.");
                        System.Diagnostics.Process.Start("https://mapsengine.google.com/admin/#RepositoryPlace:cid=" + projectId + "&v=DETAIL_INFO&aid=" + uploadingAsset.id);
                    }
                    else if (selectedLayer is ESRI.ArcGIS.Carto.IRasterLayer)
                    {
                        // export a copy of the raster to a format that can be uploaded
                        // raise a processing notification
                        ext.publishRaiseDownloadProgressChangeEvent(false, "Extracting a copy of '" + selectedLayer.Name + "' (raster) for data upload.");
                        ExportLayerToUploadableRaster(tempDir.FullName, tempDir.Name, selectedLayer);

                        processingDialog.Update();
                        processingDialog.Focus();

                        // create a list of files in the temp directory
                        List <String> filesNames = new List <String>();
                        for (int k = 0; k < tempDir.GetFiles().Count(); k++)
                        {
                            if (!tempDir.GetFiles()[k].Name.EndsWith(".lock"))
                            {
                                filesNames.Add(tempDir.GetFiles()[k].Name);
                            }
                        }

                        // create a Google Maps Engine asset record
                        ext.publishRaiseDownloadProgressChangeEvent(false, "Requesting a new Google Maps Engine asset be created.");
                        MapsEngine.DataModel.gme.UploadingAsset uploadingAsset
                            = api.createRasterAssetForUploading(ext.getToken(),
                                                                projectId,
                                                                name,
                                                                aclName,
                                                                attribution, // attribution
                                                                filesNames,
                                                                description,
                                                                tags.Split(",".ToCharArray()).ToList <String>());

                        // Initiate upload of file(s)
                        ext.publishRaiseDownloadProgressChangeEvent(false, "Starting to upload files...");
                        api.uploadFilesToAsset(ext.getToken(), uploadingAsset.id, tempDir.GetFiles());

                        // launch a web browser
                        ext.publishRaiseDownloadProgressChangeEvent(false, "Launching a web browser.");
                        System.Diagnostics.Process.Start("https://mapsengine.google.com/admin/#RepositoryPlace:cid=" + projectId + "&v=DETAIL_INFO&aid=" + uploadingAsset.id);
                    }

                    // Delete temporary directory and containing files
                    // TODO: Remove temporary files, but can't remove them at the moment because they are in use by
                    // the ArcMap seesion.
                    //tempDir.Delete(true);

                    // close the processing dialog
                    ext.publishRaiseDownloadProgressChangeEvent(true, "Finished");
                    processingDialog.Close();
                }
                else
                {
                    // display an error dialog to the user
                    System.Windows.Forms.MessageBox.Show("The selected layer is invalid or the destination configuration has not been properly set.");
                }
            }
            catch (System.Exception ex)
            {
                // Ops.
                System.Windows.Forms.MessageBox.Show("An error occured. " + ex.Message);
            }

            // close the dialog
            this.Close();
        }
		public void GenerateXmlData(string diagramName, string diagramClassName, ref object xmlSource, ref bool cancel)
		{
			MSXML2.DOMDocument xmlDOMDocument = new MSXML2.DOMDocument();
			ESRI.ArcGIS.Carto.IMaps maps;
			ESRI.ArcGIS.Carto.IMap currentMap;
			ESRI.ArcGIS.Geodatabase.IEnumFeature enumFeature;
			ESRI.ArcGIS.Geodatabase.IFeature feature;
			MSXML2.IXMLDOMProcessingInstruction xmlProcInstr;
			MSXML2.IXMLDOMElement xmlDiagrams;
			MSXML2.IXMLDOMElement xmlDiagram;
			MSXML2.IXMLDOMElement xmlFeatures;
			MSXML2.IXMLDOMElement xmlDataSources;
			MSXML2.IXMLDOMElement xmlDataSource;
			MSXML2.IXMLDOMElement xmlDataSource_Namestring;
			MSXML2.IXMLDOMElement xmlDataSource_WorkspaceInfo;
			MSXML2.IXMLDOMElement xmlWorkspaceInfo_PathName;
			MSXML2.IXMLDOMElement xmlWorkspaceInfo_WorkspaceFactoryProgID;
			MSXML2.IXMLDOMAttribute rootAtt1;
			MSXML2.IXMLDOMAttribute rootAtt2;
			ESRI.ArcGIS.Geodatabase.IEnumFeatureSetup enumFeatureSetup;
			string xmlDatabase;

			// Retrieving the selected set of features
			enumFeature = null;
			feature = null;

			m_mxDocument = (ESRI.ArcGIS.ArcMapUI.IMxDocument)m_application.Document;
			maps = m_mxDocument.Maps;
			int i = 0;
			while (i < maps.Count)
			{
				currentMap = maps.get_Item(i);
				enumFeature = (ESRI.ArcGIS.Geodatabase.IEnumFeature)currentMap.FeatureSelection;
				enumFeatureSetup = (ESRI.ArcGIS.Geodatabase.IEnumFeatureSetup)enumFeature;
				enumFeatureSetup.AllFields = true;
				feature = enumFeature.Next();
				if (feature != null) break;

				i += 1;
			}

			// if (there is no selected feature in the MxDocument, the procedure is interrupted
			if (feature == null)
			{
				MessageBox.Show("There is no feature selected. Select a set of features.", "Generate/Update XML diagrams", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				cancel = true;
				return;
			}

			//Checking the feature dataset related to the selected features
			ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass;
			string featureDatasetName;
			featureClass = (ESRI.ArcGIS.Geodatabase.IFeatureClass)feature.Class;
			featureDatasetName = featureClass.FeatureDataset.BrowseName;
			xmlDatabase = featureClass.FeatureDataset.Workspace.PathName;

			// if the selected features come from another feature dataset than the expected one, the procedure is interrupted
			if (featureDatasetName != DatasetName)
			{
				//More restrictive condition: if (xmlDatabase != "c:\Mybase.gdb" ) 
				MessageBox.Show("This component doesn't work from the selected set of features.");
				cancel = true;
				return;
			}

			// Writing the XML heading items in the DOMDocument
			xmlProcInstr = xmlDOMDocument.createProcessingInstruction("xml", "version='1.0'");
			xmlDOMDocument.appendChild(xmlProcInstr);
			xmlProcInstr = null;

			//-------- Diagrams Section START --------
			// Creating the root Diagrams element
			xmlDiagrams = xmlDOMDocument.createElement("Diagrams");
			xmlDOMDocument.documentElement = xmlDiagrams;
			rootAtt1 = xmlDOMDocument.createAttribute("xmlns:xsi");
			rootAtt1.text = "http://www.w3.org/2001/XMLSchema-instance";
			xmlDiagrams.attributes.setNamedItem(rootAtt1);

			// Creating the Diagram element for the diagram which is going to be generated
			xmlDiagram = xmlDOMDocument.createElement("Diagram");
			xmlDiagrams.appendChild(xmlDiagram);
			rootAtt1 = xmlDOMDocument.createAttribute("EnforceDiagramTemplateName");
			rootAtt1.text = "false";
			xmlDiagram.attributes.setNamedItem(rootAtt1);
			rootAtt2 = xmlDOMDocument.createAttribute("EnforceDiagramName");
			rootAtt2.text = "false";
			xmlDiagram.attributes.setNamedItem(rootAtt2);

			//-------- DataSources Section START --------
			// Creating the DataSources element 
			xmlDataSources = xmlDOMDocument.createElement("Datasources");
			xmlDiagram.appendChild(xmlDataSources);
			xmlDataSource = xmlDOMDocument.createElement("Datasource");
			xmlDataSources.appendChild(xmlDataSource);

			// Specifying the Namestring for the related Datasource element
			xmlDataSource_Namestring = xmlDOMDocument.createElement("NameString");
			xmlDataSource.appendChild(xmlDataSource_Namestring);
			xmlDataSource_Namestring.nodeTypedValue = "XMLDataSource";

			// Specifying the WorkspaceInfo for the related Datasource element
			xmlDataSource_WorkspaceInfo = xmlDOMDocument.createElement("WorkSpaceInfo");
			xmlDataSource.appendChild(xmlDataSource_WorkspaceInfo);
			xmlWorkspaceInfo_PathName = xmlDOMDocument.createElement("PathName");
			xmlDataSource_WorkspaceInfo.appendChild(xmlWorkspaceInfo_PathName);
			xmlWorkspaceInfo_PathName.nodeTypedValue = xmlDatabase;
			xmlWorkspaceInfo_WorkspaceFactoryProgID = xmlDOMDocument.createElement("WorkspaceFactoryProgID");
			xmlDataSource_WorkspaceInfo.appendChild(xmlWorkspaceInfo_WorkspaceFactoryProgID);
			xmlWorkspaceInfo_WorkspaceFactoryProgID.nodeTypedValue = "esriDataSourcesGDB.FileGDBWorkspaceFactory";
			//-------- DataSources Section END --------

			//-------- Features Section START --------
			xmlFeatures = xmlDOMDocument.createElement("Features");
			xmlDiagram.appendChild(xmlFeatures);
			while (feature != null)
			{
				switch (feature.FeatureType)
				{
					case ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimpleJunction:
						CreateXMLNodeElt(feature, ref xmlDOMDocument, ref xmlFeatures, feature.Class.AliasName);
						break;
					case ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimpleEdge:
						CreateXMLLinkElt(feature, ref xmlDOMDocument, ref xmlFeatures, feature.Class.AliasName);
						break;
				}
				feature = enumFeature.Next();

			}

			// output the XML we created
			xmlSource = xmlDOMDocument;
			cancel = false;
			//-------- Features Section END --------
			//-------- Diagrams Section END --------

		}
Example #11
0
        private void fmSearchResults_Shown(object sender, EventArgs e)
        {
            try
            {
                m_bShowHTE = false;
                this.setHTEVisibility();

                this.Cursor = Cursors.WaitCursor;

                //Application.DoEvents();

                ESRI.ArcGIS.ArcMapUI.IMxDocument pMxDoc = (ESRI.ArcGIS.ArcMapUI.IMxDocument) this.App.Document;
                IMap          pMap = (IMap)pMxDoc.FocusMap;
                IFeatureLayer pLayer;

                using (CSpatialSubs oSpatialSubs = new CSpatialSubs())
                {
                    pLayer = (IFeatureLayer)oSpatialSubs.returnFeatureLayer(pMap, SConst.Taxlots);
                }

                ICursor pCurs;

                IFeatureSelection pFSel = (IFeatureSelection)pLayer;
                pFSel.SelectionSet.Search(null, true, out pCurs);

                IFeatureCursor pFCurs = (IFeatureCursor)pCurs;
                IFeature       pFeat  = pFCurs.NextFeature();

                //Application.DoEvents();

                decimal dImpVal  = decimal.Parse(pFeat.get_Value(pFeat.Fields.FindField("IMPVALUE")).ToString());
                decimal dLandVal = decimal.Parse(pFeat.get_Value(pFeat.Fields.FindField("LANDVALUE")).ToString());

                lblAcctNumber.Text   = pFeat.get_Value(pFeat.Fields.FindField("ACCOUNT")).ToString();
                lblFeeOwner.Text     = pFeat.get_Value(pFeat.Fields.FindField("FEEOWNER")).ToString();
                lblImpValue.Text     = (dImpVal).ToString("C");
                lblLandValue.Text    = (dLandVal).ToString("C");
                lblMailingAddr.Text  = pFeat.get_Value(pFeat.Fields.FindField("ADDRESS1")).ToString();
                lblMailingAddr2.Text = pFeat.get_Value(pFeat.Fields.FindField("CITY")).ToString() + "," + pFeat.get_Value(pFeat.Fields.FindField("STATE")).ToString() + " " + pFeat.get_Value(pFeat.Fields.FindField("ZIPCODE")).ToString();
                lblMaplotNumber.Text = pFeat.get_Value(pFeat.Fields.FindField("MAPLOT")).ToString();
                //lblSitusAddr.Text = pFeat.get_Value(pFeat.Fields.FindField("ADDRESSNUM")).ToString() + " " + pFeat.get_Value(pFeat.Fields.FindField("STREETNAME")).ToString();
                lblLocID.Text = this.LocationID.ToString();

                lblPropClass.Text     = pFeat.get_Value(pFeat.Fields.FindField("PROPCLASS")).ToString();
                lblPropClassDesc.Text = CMedToolsSubs.returnPropClassDescription(pFeat.get_Value(pFeat.Fields.FindField("PROPCLASS")).ToString(), CMedToolsSubs.getPropClass());

                string sFormattedTaxCode = CMedToolsSubs.returnTaxCodeFormatted(pFeat.get_Value(pFeat.Fields.FindField("TAXCODE")).ToString());

                lblTaxcode.Text = sFormattedTaxCode;
                string[] aTaxCodeInfo = CMedToolsSubs.returnTaxCodeInfo(sFormattedTaxCode, CMedToolsSubs.getTaxCodes());

                if (aTaxCodeInfo != null)
                {
                    lblTaxCodeCity.Text       = aTaxCodeInfo[0].ToString();
                    lblTaxCodeSchool.Text     = aTaxCodeInfo[1].ToString();
                    lblTaxCodeWater.Text      = aTaxCodeInfo[2].ToString();
                    lblTaxCodeUrbanRenew.Text = aTaxCodeInfo[3].ToString();
                    lblTaxCodeFireDist.Text   = aTaxCodeInfo[4].ToString();
                }
                else
                {
                    lblTaxCodeCity.Text       = "";
                    lblTaxCodeSchool.Text     = "";
                    lblTaxCodeWater.Text      = "";
                    lblTaxCodeUrbanRenew.Text = "";
                    lblTaxCodeFireDist.Text   = "";
                }

                //getLXInfo(pFeat.get_Value(pFeat.Fields.FindField("ACCOUNT")).ToString(), pFeat.get_Value(pFeat.Fields.FindField("MAPNUM")).ToString(), pFeat.get_Value(pFeat.Fields.FindField("TAXLOT")).ToString());

                //Application.DoEvents();

                if (this.LocationID < 1)
                {
                    if (SConst.GotDBConn)
                    {
                        // this should be a Medford Address
                        using (CData oData = new CData(SConst.LXConnString.ToString()))
                        {
                            lblSitusAddr.Text = oData.returnSitusAddressByLocID(this.LocationID);
                        }
                    }
                    //else
                    //tabControl1.Enabled = false;
                }
                else
                {
                    // this should be a county address
                    lblSitusAddr.Text = pFeat.get_Value(pFeat.Fields.FindField("ADDRESSNUM")).ToString() + " " + pFeat.get_Value(pFeat.Fields.FindField("STREETNAME")).ToString();
                    //tabControl1.Enabled = false;
                }

                this.Cursor = Cursors.Default;
                //Application.DoEvents();
            }
            catch (Exception ex)
            {
                string s = ex.Message;
                s += "- --- that was it";
            }
        }