qq_35202555
qq_35202555
2016-06-19 13:38

新人求教。下面代码各什么意思

15

private void all_track(int id)
{
//datagridview中写入数据
string scn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=数据表.mdb";
OleDbConnection mycn = new OleDbConnection(scn);

        mycn.Open();
        OleDbCommand mycmd = new OleDbCommand();
        mycmd.Connection = mycn;
        mycmd.CommandType = CommandType.Text;

        string c = "select * from point1 where id='" + id + "'";

        mycmd.CommandText = c;
        OleDbDataAdapter add = new OleDbDataAdapter(mycmd);
        DataSet ds = new DataSet();
        add.Fill(ds, "a");
        DataTable dt = new DataTable();
        dt = ds.Tables["a"];


        string name;
        IPointCollection ppc = new PolylineClass();
        for (int i = 0; i < dt.Rows.Count; i++)
        {

            name = dt.Rows[i]["id"].ToString();
            name = name.Trim();
            double x = Convert.ToDouble(dt.Rows[i]["x"]);
            double y = Convert.ToDouble(dt.Rows[i]["y"]);
            ITextElement pte = new TextElementClass();
            ISimpleTextSymbol psts = new TextSymbolClass();
            IRgbColor prc = new RgbColorClass();

            IFont mf = new StdFontClass();
            mf.Name = "宋体";//Courier New
            IFontDisp mt = mf as IFontDisp;
            psts.Font = mt;
            psts.Size = 18;
            pte.Symbol = psts;
            pte.Text = name;
            IElement pelt = pte as IElement;
            IElementProperties pelet = pelt as IElementProperties;
            pelet.Name = name;
            IElement pel = new MarkerElementClass();
            IPoint pp = new PointClass();
            pp.PutCoords(x, y);
            ppc.AddPoints(1, ref pp);
            pel.Geometry = pp;
            pelt.Geometry = pp;
            IElementProperties pele = pel as IElementProperties;
            pele.Name = name;
            ISimpleMarkerSymbol psm = new SimpleMarkerSymbolClass();
            IRgbColor prg = new RgbColorClass();
            IMarkerElement pme = pel as IMarkerElement;
            IRgbColor prgb = new RgbColorClass();

            pgc.AddElement(pel, 0);

            pgc.AddElement(pelt, 0);

            this.axMapControl1.ActiveView.Refresh();

        }

        IPolyline ppl = ppc as IPolyline;
        IElement pele1 = new LineElementClass();
        pele1.Geometry = ppl;

        ILineElement ple = pele1 as ILineElement;
        ISimpleLineSymbol psl = new SimpleLineSymbolClass();
        //psl.Style = esriSimpleLineStyle.esriSLSSolid;   // ctrl + J
        IRgbColor prg1 = new RgbColorClass();

        pgc.AddElement(pele1, 0);
        this.axMapControl1.ActiveView.Refresh();
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答