Exemplo n.º 1
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            DataTable    table = MapDBClass.GetPropertyDefine((comboBox1.SelectedIndex + 1).ToString());
            DataGridView view  = dataGridView1;

            view.Rows.Clear();
            for (int i = 0; i < table.Rows.Count; i++)
            {
                int row = view.Rows.Add();
                view.Rows[row].Cells[0].Value         = table.Rows[i]["PropertyName"];
                view.Rows[row].Cells["oldname"].Value = table.Rows[i]["PropertyName"];
                view.Rows[row].Cells[1].Value         = table.Rows[i]["DataType"];
                view.Rows[row].Cells[2].Value         = "";
                view.Rows[row].Cells[3].Value         = "";
                if (table.Rows[i]["DataType"].ToString() == "列表")
                {
                    view.Rows[row].Cells[2].Value = table.Rows[i]["AllowUnSelect"].ToString() == "1" ? "允许" : "不允许";
                    view.Rows[row].Cells[3].Value = table.Rows[i]["AllowInput"].ToString() == "1" ? "允许" : "不允许";
                }
                view.Rows[row].Cells[6].Value          = table.Rows[i]["AllowVisible"].ToString() == "1" ? "允许" : "不允许";
                view.Rows[row].Cells[4].Value          = table.Rows[i]["List"];
                view.Rows[row].Cells["isnewrow"].Value = "0";
            }
            btnOk.Enabled   = true;
            button4.Enabled = true;
        }
        private void Search()
        {
            bool allowedit = GetCurrentLayer() != null && GetCurrentLayer() == _EditLayer;

            dataGridView1.ReadOnly = !allowedit;
            btnOk.Enabled          = allowedit;
            txtMessage.ReadOnly    = !allowedit;
            textBox1.ReadOnly      = !allowedit;
            paste.Enabled          = allowedit;

            dataGridView1.Rows.Clear();
            comboBox1.Items.Clear();
            textBox1.Text   = "";
            textBox2.Text   = "";
            textBox3.Text   = "";
            txtMessage.Text = "";
            _LayerId        = GetCurrentLayer().ID;
            _Object         = GetSelectObject();
            _type           = GetCurrentLayerType();
            _Selected       = false;
            comboBox1.Items.Clear();
            comboBox1.Text  = "";
            textBox1.Text   = _Object.Text;
            txtMessage.Text = _Object.Message;
            _table          = MapDBClass.GetPropertyDefine(_type.ToString());
            string    sql       = "select * from " + MapDBClass.GetPropertyTableName(_MapId, _LayerId) + " where 1<>1";
            DataTable temptable = SqlHelper.Select(sql, null);

            for (int i = 4; i < temptable.Columns.Count; i++)
            {
                bool find = false;
                for (int j = 0; j < _table.Rows.Count; j++)
                {
                    if (temptable.Columns[i].ColumnName.ToLower() == _table.Rows[j]["PropertyName"].ToString().ToLower())
                    {
                        find = true;
                        break;
                    }
                }
                if (find)
                {
                    continue;
                }
                _table.Rows.Add(new object[] { i, _type.ToString(), temptable.Columns[i].ColumnName, temptable.Columns[i].DataType.Name, "0", "0", "", "1" });
            }
            SetDateList();
            textBox2.Text = "";
            textBox3.Text = "";
            Geometry selobject = _Object;

            if (selobject is Polygon)
            {
                Polygon polygon = selobject as Polygon;
                textBox2.Text = String.Format("{0:N5}", polygon.Area);
                textBox3.Text = String.Format("{0:N5}", polygon.ExteriorRing.Length);
            }
            else if (selobject is MultiPolygon)
            {
                MultiPolygon multiPolygon = selobject as MultiPolygon;
                textBox2.Text = String.Format("{0:N5}", multiPolygon.Area);
                textBox3.Text = String.Format("{0:N5}", multiPolygon.Length);
            }
            else if (selobject is LinearRing)
            {
                LinearRing line = selobject as LinearRing;
                textBox3.Text = String.Format("{0:N5}", line.Length);
            }
            else if (selobject is LineString)
            {
                LineString line = selobject as LineString;
                textBox3.Text = String.Format("{0:N5}", line.Length);
            }
            else if (selobject is MultiLineString)
            {
                MultiLineString line = selobject as MultiLineString;
                textBox3.Text = String.Format("{0:N5}", line.Length);
            }
        }