public FormFindSample()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //

            //
            // Create a connection object and open it.
            //
            this._miConnection = new MIConnection();
            _miConnection.Open();

            //
            // Create a command object to hold parameters and last command executed
            //
            this._miCommand = _miConnection.CreateCommand();

            buttonFind.Enabled = false;
            checkBoxUseCloseMatches.Checked = true;
            listBoxSearchResult.Visible = false;
            textBoxMaxCloseMatches.Text = "5";
        }
Esempio n. 2
0
        private void FillDropDown(string tableName, string colName)
        {
            MapInfo.Mapping.Map map = null;

            // Get the map
            if (MapInfo.Engine.Session.Current.MapFactory.Count == 0 ||
                (map = MapInfo.Engine.Session.Current.MapFactory[MapControl1.MapAlias]) == null)
            {
                return;
            }

            DropDownList1.Items.Clear();
            MapInfo.Mapping.FeatureLayer fl = (MapInfo.Mapping.FeatureLayer)map.Layers[tableName];
            MapInfo.Data.Table           t  = fl.Table;
            MIDataReader tr;
            MIConnection con = new MIConnection();
            MICommand    tc  = con.CreateCommand();

            tc.CommandText = "select " + colName + " from " + t.Alias;
            con.Open();
            tr = tc.ExecuteReader();
            while (tr.Read())
            {
                DropDownList1.Items.Add(tr.GetString(0));
            }
            tc.Cancel();
            tc.Dispose();
            tr.Close();
            con.Close();
            //t.Close();
        }
Esempio n. 3
0
        public FormFindSample()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //

            //
            // Create a connection object and open it.
            //
            this._miConnection = new MIConnection();
            _miConnection.Open();

            //
            // Create a command object to hold parameters and last command executed
            //
            this._miCommand = _miConnection.CreateCommand();

            buttonFind.Enabled = false;
            checkBoxUseCloseMatches.Checked = true;
            listBoxSearchResult.Visible     = false;
            textBoxMaxCloseMatches.Text     = "5";
        }
Esempio n. 4
0
 private void CleanUp()
 {
     if (_miCommand != null)
     {
         _miCommand.Dispose();
         _miCommand = null;
     }
     if (_miConnection != null)
     {
         _miConnection.Close();
         _miConnection = null;
     }
     Session.Current.Catalog.CloseAll();
     Session.Dispose();
 }
Esempio n. 5
0
 private void SetDataGrid(DataGrid dataGrid, string commandText, bool bShowSchema)
 {
     MapInfo.Data.MIConnection miConnection = new MIConnection();
     miConnection.Open();
     MapInfo.Data.MICommand miCommand = miConnection.CreateCommand();
     miCommand.CommandText = commandText;
     MapInfo.Data.MIDataReader miReader = null;
     try
     {
         miReader = miCommand.ExecuteReader();
         if (bShowSchema)
         {
             dataGrid.DataSource = miReader.GetSchemaTable();
         }
         else
         {
             DataTable dt = new DataTable("Data");
             for (int index = 0; index < miReader.FieldCount; index++)
             {
                 DataColumn dc = dt.Columns.Add(miReader.GetName(index));
             }
             while (miReader.Read())
             {
                 DataRow dr = dt.NewRow();
                 for (int index = 0; index < miReader.FieldCount; index++)
                 {
                     dr[index] = miReader.GetValue(index);
                 }
                 dt.Rows.Add(dr);
             }
             dataGrid.DataSource = dt;
         }
     }
     catch (Exception)
     {
         SelectClauseTextBox.Text += " ***Wrong select clause, try it.***";
     }
     finally
     {
         if (miReader != null)
         {
             miReader.Close();
         }
     }
 }
Esempio n. 6
0
 private void SetDataGrid(DataGrid dataGrid, string commandText, bool bShowSchema)
 {
     MapInfo.Data.MIConnection miConnection = new MIConnection();
     miConnection.Open();
     MapInfo.Data.MICommand miCommand = miConnection.CreateCommand();
     miCommand.CommandText = commandText;
     MapInfo.Data.MIDataReader miReader = null;
     try
     {
         miReader = miCommand.ExecuteReader();
         if (bShowSchema)
         {
             dataGrid.DataSource = miReader.GetSchemaTable();
         }
         else
         {
             DataTable dt = new DataTable("Data");
             for (int index = 0; index < miReader.FieldCount; index++)
             {
                 DataColumn dc = dt.Columns.Add(miReader.GetName(index));
             }
             while (miReader.Read())
             {
                 DataRow dr = dt.NewRow();
                 for (int index = 0; index < miReader.FieldCount; index++)
                 {
                     dr[index] = miReader.GetValue(index);
                 }
                 dt.Rows.Add(dr);
             }
             dataGrid.DataSource = dt;
         }
     }
     catch(Exception)
     {
         SelectClauseTextBox.Text +=  " ***Wrong select clause, try it.***";
     }
     finally
     {
         if(miReader != null)
         {
             miReader.Close();
         }
     }
 }
 private void CleanUp()
 {
     if ( _miCommand != null )
     {
         _miCommand.Dispose();
         _miCommand = null;
     }
     if ( _miConnection != null )
     {
         _miConnection.Close();
         _miConnection = null;
     }
     Session.Current.Catalog.CloseAll();
     Session.Dispose();
 }
Esempio n. 8
0
        private string DetermineRemoteGeomType(FeatureLayer layer)
        {
            MapInfo.Data.Table   t     = layer.Table;
            MapInfo.Styles.Style style = null;

            MIConnection con = null;
            MICommand    cmd = null;
            MIDataReader dr  = null;

            try {
                con = new MIConnection();
                con.Open();
                cmd             = con.CreateCommand();
                cmd.CommandText = "select mi_style from \"" + t.Alias + "\"";
                cmd.CommandType = System.Data.CommandType.Text;
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    if (!dr.IsDBNull(0))
                    {
                        style = dr.GetStyle(0);
                        break;
                    }
                }
            }
            catch (MIException) {
                // e.g. if there is no mi_style column
            }
            finally {
                if (cmd != null)
                {
                    cmd.Dispose();
                    cmd = null;
                }
                if (dr != null)
                {
                    dr.Close();
                }
                if (con != null)
                {
                    con.Close();
                    con = null;
                }
            }

            if (style != null)
            {
                if (style is SimpleLineStyle)
                {
                    return("lclayerline.bmp");
                }
                else if (style is SimpleInterior || style is AreaStyle)
                {
                    return("lclayerregion.bmp");
                }
                else if (style is BasePointStyle)
                {
                    return("lclayerpoint.bmp");
                }
                else
                {
                    return("lclayer.bmp");
                }
            }
            else
            {
                return(null);
            }
        }
Esempio n. 9
0
        private void FillDropDown(string tableName, string colName)
        {
            MapInfo.Mapping.Map map = null;

            // Get the map
            if (MapInfo.Engine.Session.Current.MapFactory.Count == 0 ||
                (map = MapInfo.Engine.Session.Current.MapFactory[MapControl1.MapAlias]) == null)
            {
                return;
            }

            DropDownList1.Items.Clear();
            MapInfo.Mapping.FeatureLayer fl = (MapInfo.Mapping.FeatureLayer)map.Layers[tableName];
            MapInfo.Data.Table  t = fl.Table;
            MIDataReader tr;
            MIConnection con = new MIConnection();
            MICommand tc = con.CreateCommand();
            tc.CommandText = "select " + colName + " from " + t.Alias ;
            con.Open();
            tr = tc.ExecuteReader() ;
            while (tr.Read())
            {
                DropDownList1.Items.Add(tr.GetString(0));
            }
            tc.Cancel();
            tc.Dispose();
            tr.Close() ;
            con.Close();
            //t.Close();
        }
Esempio n. 10
0
        public MainForm()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            ToolBarSetup();

            //
            // Create a connection object and open it.
            //
            miConnection = new MIConnection();
            miConnection.Open();

            //
            // Create a command object to hold parameters and last command executed
            //
            miCommand = miConnection.CreateCommand();

            // Add a few default parameters
            CoordSysFactory CSysFactory = Session.Current.CoordSysFactory;
            CoordSys Robinson = CSysFactory.CreateFromPrjString("12, 62, 7, 0");
            CoordSys LatLong = CSysFactory.CreateFromPrjString("1, 0");
            CoordSys NAD83 = CSysFactory.CreateFromPrjString("1, 74");
            miCommand.Parameters.Add("RobinsonCSys", Robinson);
            miCommand.Parameters.Add("LatLongCSys", LatLong);
            miCommand.Parameters.Add("NAD83CSys", NAD83);

            // Set table search path to value sampledatasearch registry key
            // if not found, then use the sampledatasearchpath
            // if that is not found, then just use the app's current directory
            Microsoft.Win32.RegistryKey keyApp = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(@"SOFTWARE\MapInfo\MIDataExplorer");

            string s = (string)keyApp.GetValue("TableSearchPath");
            if (s == null || s.Length == 0)
            {
                Microsoft.Win32.RegistryKey keySamp = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"SOFTWARE\MapInfo\MapXtreme\6.6");
                s = (string)keySamp.GetValue("SampleDataSearchPath");
                if (s != null && s.Length > 0)
                {
                    if (s.EndsWith("\\")==false)
                    {
                        s += "\\";
                    }
                }
                else
                {
                    s = Environment.CurrentDirectory;
                }
                keySamp.Close();
            }
            keyApp.Close();

            Session.Current.TableSearchPath.Path = s;

            ProcessCommand("help"); // show commands

            // For sample app purposes, open states.tab
            if (Session.Current.TableSearchPath.FileExists("usa.tab"))
            {
                ProcessCommand("open usa.tab");
                // For sample app purposes, load states.sql if we can find it.
                string sFound;
                if (Session.Current.TableSearchPath.FileExists("sample.sql", out sFound))
                {
                    rtCommand.LoadFile(sFound, RichTextBoxStreamType.PlainText);
                }
                else
                {
                    // could not open a command file, but we want to show something
                    ProcessCommand("select * from usa");
                }
            }
        }
        private string DetermineRemoteGeomType(FeatureLayer layer)
        {
            MapInfo.Data.Table t = layer.Table;
            MapInfo.Styles.Style style = null;

            MIConnection con = null;
            MICommand cmd = null;
            MIDataReader dr = null;
            try {
                con = new MIConnection();
                con.Open();
                cmd = con.CreateCommand();
                cmd.CommandText = "select mi_style from \"" + t.Alias + "\"";
                cmd.CommandType = System.Data.CommandType.Text;
                dr = cmd.ExecuteReader();
                while (dr.Read()) {
                    if (!dr.IsDBNull(0)) {
                        style = dr.GetStyle(0);
                        break;
                    }
                }
            }
            catch (MIException) {
                // e.g. if there is no mi_style column
            }
            finally {
                if (cmd != null) {
                    cmd.Dispose();
                    cmd = null;
                }
                if (dr != null) {
                    dr.Close();
                }
                if (con != null) {
                    con.Close();
                    con = null;
                }
            }

            if (style != null) {
                if (style is SimpleLineStyle) {
                    return "lclayerline.bmp";
                }
                else if (style is SimpleInterior || style is AreaStyle) {
                    return "lclayerregion.bmp";
                }
                else if (style is BasePointStyle) {
                    return "lclayerpoint.bmp";
                } else {
                    return "lclayer.bmp";
                }
            } else {
                return null;
            }
        }