Exemplo n.º 1
0
        /// <summary>
        /// Reset the _tableEnum field to the table being displayed, if any
        /// </summary>
        private void ResetTableEnum()
        {
            bool bFound = false;
            int  index  = 0;

            _tableEnum = null;
            _tableEnum = Session.Current.Catalog.EnumerateTables(
                TableFilterFactory.FilterAllTables());

            while (_tableEnum.MoveNext())
            {
                index++;
                if (String.Equals(_tableEnum.Current.Alias, _tableAlias))
                {
                    bFound = true;
                    break;
                }
            }
            if (!bFound)
            {
                _tableEnum.Reset();
                _tableEnum.MoveNext();
                _tableIndex = 1;
            }
            else
            {
                _tableIndex = index;
            }
        }
Exemplo n.º 2
0
        private void button2_Click(object sender, System.EventArgs e)
        {
            int n = 0;

            Table []         tables = null;
            ITableEnumerator tenum  = Session.Current.Catalog.EnumerateTables(TableFilterFactory.FilterMappableTables());

            while (tenum.MoveNext())
            {
                n++;
            }
            tables = new Table[n];
            n      = 0;
            foreach (Table t in tenum)
            {
                tables[n++] = t;
            }

            NewMapDlg dlg;

            if (n > 0)
            {
                dlg = new NewMapDlg(tables);
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    // build map using MapTableLoader
                    tables = dlg.SelectedTables;
                    n      = dlg.SelectionCount;
                }
                else
                {
                    return;
                }
            }
            // now build map from tables if any
            Map m;

            if (n == 0)
            {
                m = Session.Current.MapFactory.CreateEmptyMap(null, null, IntPtr.Zero, mapControl1.Size);
            }
            else
            {
                m = Session.Current.MapFactory.Create(IntPtr.Zero, mapControl1.Size, new MapTableLoader(tables));
            }
            SetMap(m);
            UpdateMapComboBox();
        }
Exemplo n.º 3
0
        // search through all tables to find objects that intersect
        // the states bordering KS
        private void menuItemSearchMultipleTables_Click(object sender, System.EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                // find states that intersect KS
                // then combine them and search all layers within
                // also uses search for feature
                Feature    fKS = _catalog.SearchForFeature("usa", MapInfo.Data.SearchInfoFactory.SearchWhere("State='KS'"));
                SearchInfo si  = MapInfo.Data.SearchInfoFactory.SearchIntersectsFeature(fKS, IntersectType.Geometry);
                IResultSetFeatureCollection fc = _catalog.Search("usa", si);

                MapInfo.FeatureProcessing.FeatureProcessor fp = new MapInfo.FeatureProcessing.FeatureProcessor();
                Feature f = fp.Combine(fc);

                si = MapInfo.Data.SearchInfoFactory.SearchWithinFeature(f, ContainsType.Centroid);
                MultiResultSetFeatureCollection mfc = _catalog.Search(_catalog.EnumerateTables(TableFilterFactory.FilterMappableTables()), si);

                // set map view to show search results
                _map.SetView(f);

                ShowSearchGeometry(f.Geometry);

                // show results as selection
                SelectFeatureCollection(fc);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }