Esempio n. 1
0
        private void listBoxSearchResult_DoubleClick(object sender, System.EventArgs e)
        {
            // get the selected object
            string selectedCloseMatch = (string)this.listBoxSearchResult.SelectedItem;
            // get the selected object index in the list as well since multiple matches
            // may have the same name - we can't just compare close match names.
            int selectedIndex = this.listBoxSearchResult.SelectedIndex;
            int currentIndex  = 0;

            // create a close match object
            FindCloseMatch closeMatch = null;

            // create an enumerator from the results
            FindCloseMatchEnumerator enumerator = _result.GetCloseMatchEnumerator();

            while (enumerator.MoveNext())
            {
                // if the selected name equals the enumerated name...
                if (currentIndex == selectedIndex && selectedCloseMatch.Equals(enumerator.Current.Name))
                {
                    // set the close match object
                    closeMatch = enumerator.Current;

                    // break out of the loop
                    break;
                }
                // else keep looking
                currentIndex++;
            }
            if (closeMatch != null)
            {
                // create the command string
                string command = "select obj from " + _searchTable.Alias + " where MI_Key = \'" + closeMatch.Key + "\'";

                // create the command object
                MICommand cmd = _miConnection.CreateCommand();
                cmd.CommandText = command;

                // create the reader by executing the command
                MIDataReader rdr = cmd.ExecuteReader();

                // read a row
                rdr.Read();

                // get the point
                MapInfo.Geometry.DPoint point = rdr.GetFeatureGeometry(0).Centroid;

                // Close the reader and dispose of the command.
                rdr.Close();
                cmd.Cancel();
                cmd.Dispose();

                // show point on a map
                showPointOnSearchTableMap(point.x, point.y);
            }
        }
Esempio n. 2
0
        // Gets RasterInfo from a given table.
        // Each raster table has exactly one associated raster image, and thus only one record.
        // Reading that record with a data reader, we can get
        // a FeatureGeometry - a bounding rectangle,
        // a Style - the Raster style,
        // a key
        // a RasterInfo object.
        private MapInfo.Raster.RasterInfo GetRasterInfo(Table table)
        {
            MapInfo.Raster.RasterInfo rasterInfo = null;
            MIDataReader rdr            = null;
            string       projectionlist = "obj, MI_Key, MI_Raster, MI_Style";

            rdr = table.ExecuteReader(projectionlist);

            string name;
            string typename;
            int    n = rdr.FieldCount;

            MapInfo.Styles.Style             style;
            MapInfo.Geometry.FeatureGeometry featureGeometry;
            MapInfo.Data.Key key;
            if (rdr.Read())
            {
                for (int i = 0; i < rdr.FieldCount; i++)
                {
                    name     = rdr.GetName(i);
                    typename = rdr.GetDataTypeName(i);
                    if (typename == "MapInfo.Styles.Style")
                    {
                        style = rdr.GetStyle(i);
                    }
                    else if (typename == "MapInfo.Geometry.FeatureGeometry")
                    {
                        featureGeometry = rdr.GetFeatureGeometry(i);
                    }
                    else if (typename == "MapInfo.Data.Key")
                    {
                        key = rdr.GetKey(i);
                    }
                    else if (typename == "MapInfo.Raster.RasterInfo")
                    {
                        rasterInfo = rdr.GetRasterInfo(i);
                    }
                }
            }
            rdr.Close();
            rdr.Dispose();
            rdr = null;
            return(rasterInfo);
        }
Esempio n. 3
0
		public void SelectAllIndivColumns()
		{
			MIDataReader rdr = null;
			string projectionlist = "obj, MI_Key, MI_Grid, MI_Style";
			rdr = _miTable.ExecuteReader(projectionlist);
			
			string name;
			string typename;
			int n = rdr.FieldCount;
			if(rdr.Read())
			{
				n = rdr.FieldCount;//shouldn't change
				for(int i =0; i <n; i++)
				{
					name = rdr.GetName(i);
					typename = rdr.GetDataTypeName(i);
					if(typename == "MapInfo.Styles.Style")
					{
						_mStyle = rdr.GetStyle(i) as GridStyle; 
					}
					else if(typename == "MapInfo.Geometry.FeatureGeometry")
					{
						_mObject = rdr.GetFeatureGeometry(i);
					}
					else if(typename == "MapInfo.Data.Key")
					{
						_mKey = rdr.GetKey(i);
					}
					else if (typename == "MapInfo.Raster.GridInfo")
					{
						_mGridInfo = rdr.GetGridInfo(i);
					}
				}
			}

			rdr.Close();
			rdr.Dispose();
			rdr = null;
		}