qq_35202555 2016-06-19 13:38 采纳率: 66.7%
浏览 1274
已采纳

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

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条回答 默认 最新

  • devmiao 2016-06-19 13:45
    关注

    private void all_track(int id)
    {
    //datagridview中写入数据
    string scn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=数据表.mdb"; 读取access数据源
    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 + "'"; 查询符合的id
    
        mycmd.CommandText = c; 设置sql语句
        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(); 取得id
            name = name.Trim(); 对名字截取,去到空格
            double x = Convert.ToDouble(dt.Rows[i]["x"]); x坐标
            double y = Convert.ToDouble(dt.Rows[i]["y"]); 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); 添加pel
    
            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(); 刷新
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?