zoukankan      html  css  js  c++  java
  • mo+c#中的 tips 实现

    using System; 
    using System.Drawing; 
    using System.Collections; 
    using System.ComponentModel; 
    using System.Windows.Forms; 
    using System.Data; 

    namespace WindowsApplication67 

     
    /// 
     
    /// Form1 的摘要说明。 
     
    /// 

     public class Form1 : System.Windows.Forms.Form 
     

      
    private AxMapObjects2.AxMap axMap1; 
      
    private System.Windows.Forms.TextBox textBox1; 
      
    private System.Windows.Forms.Timer timer1; 
      
    private System.ComponentModel.IContainer components; 
            
    public maptips2  tips; 

      
    public Form1() 
      

       
    // 
       
    // Windows 窗体设计器支持所必需的 
       
    // 
       InitializeComponent(); 

       
    // 
       
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码 
       
    // 
      }
     

      
    /// 
      
    /// 清理所有正在使用的资源。 
      
    /// 

      protected override void Dispose( bool disposing ) 
      

       
    if( disposing ) 
       

        
    if (components != null
        

         components.Dispose(); 
        }
     
       }
     
       
    base.Dispose( disposing ); 
      }
     

      
    Windows 窗体设计器生成的代码 

      
    /// 
      
    /// 应用程序的主入口点。 
      
    /// 

      [STAThread] 
      
    static void Main() 
      

       Application.Run(
    new Form1()); 
      }
     

      
    private void Form1_Load(object sender, System.EventArgs e) 
      

       MapObjects2.IMoDataConnection  dc; 
       MapObjects2.IMoMapLayer  layer; 
       dc
    =new MapObjects2.DataConnectionClass(); 
       dc.Database
    =@"f:\data\usa"
       
    if (!dc.Connect()) 
       

        MessageBox.Show(
    "无法连"); 
       }
     
       
    else 
       

        layer
    =new MapObjects2.MapLayerClass(); 
        layer.GeoDataset
    =dc.FindGeoDataset("STATES"); 
        axMap1.Layers.Add(layer); 

       

       tips
    =new maptips2(); 
       tips.initialize(axMap1,timer1,textBox1); 
                tips.setlay(layer,
    "STATE_NAME"); 

    }
     
      }
     

      
    private void axMap1_MouseDownEvent(object sender, AxMapObjects2._DMapEvents_MouseDownEvent e) 
      

       MapObjects2.Rectangle  r; 
       r
    =   new MapObjects2.RectangleClass(); 
       r
    =axMap1.TrackRectangle() ; 

       axMap1.Extent
    =r;

      }


      
    private void axMap1_MouseMoveEvent(object sender, AxMapObjects2._DMapEvents_MouseMoveEvent e) 
      

       
    this.tips.mousemove(e.x,e.y ); 
      }
     

      
    private void timer1_Tick(object sender, System.EventArgs e) 
      

       
    this.tips.timer(); 
      }
     
     }
     
    }
     

























    //

    using System; 
    using MapObjects2; 

    namespace WindowsApplication67 

     
    /// 
     
    /// maptips2 的摘要说明。 
     
    /// 

     public class maptips2 
     

      
    public maptips2() 
      

       
    // 
       
    // TODO: 在此处添加构造函数逻辑 
       
    // 
      }
     
      
    protected int  m_x; 
      
    protected int  m_y; 
      
    protected int  m_lastx; 
      
    protected int  m_lasty; 
            
    protected  AxMapObjects2.AxMap axMap1; 
      
    protected  System.Windows.Forms.Timer m_time; 
      
    protected  System.Windows.Forms.TextBox m_edit; 
      
    protected  MapObjects2.IMoMapLayer  m_layer; 
      
    protected  string  m_field; 
      
    protected  MapObjects2.Recordset m_recs; 

      
    public void doseach() 
      

       MapObjects2.Point  pt; 
       pt
    =new MapObjects2.PointClass(); 
       pt
    =axMap1.ToMapPoint(m_x,m_y); 
       
    if (m_layer.shapeType.ToString()=="23"
       

        m_recs
    =m_layer.SearchShape(pt,MapObjects2.SearchMethodConstants.moPointInPolygon ,""); 
         

       }
     
       
    else 
       

        m_recs
    =m_layer.SearchByDistance(pt,axMap1.ToMapDistance(10),""); 

       }
     
        

      }
     
      
    public void initialize(AxMapObjects2.AxMap  map,System.Windows.Forms.Timer tmr,System.Windows.Forms.TextBox edit ) 
      

       axMap1
    =map; 
       m_time
    =tmr; 
       m_edit
    =edit; 
       m_edit.Visible
    =false


      }
     
      
    public void mousemove(int x,int y) 
      

       
    if ( m_time.Interval==1
       

        m_x
    =x; 
        m_y
    =y; 
        m_time.Interval
    =100
       }
     
       
    else 
       

        m_edit.Visible
    =false

       }
     
      }
     
      
    public void setlay(MapObjects2.IMoMapLayer  layer,string fid) 
      

       m_layer
    =layer; 
       m_field
    =fid; 

      }
     
      
    public void showtiptext(string text) 
      

              m_edit.Text
    =text; 
              m_edit.Visible
    =true
              m_edit.Left
    =axMap1.Left+m_x; 
              m_edit.Top 
    =axMap1.Top+m_y+20

      }
     
      
    public void timer() 
      

       
    string s; 
       MapObjects2.IMoFields flds; 
       MapObjects2.IMoField fld ; 
       
    if ((m_x==m_lastx)&&(m_y==m_lasty)) 
       

        m_time.Interval
    =1
        doseach(); 
        
    if(m_recs.EOF ) 
        

         m_edit.Visible
    =false

        }
     
        
    else 
        

         flds
    =m_recs.Fields ; 
         fld
    = flds.Item(m_field); 
         s
    =fld.Value.ToString(); 
         
    this.showtiptext(s); 


        }
     
                  
       }
     
       
    else 
       

        m_lastx
    =m_x; 
        m_lasty
    =m_y; 

       }


        
      }
     



     }
     
    }
     

  • 相关阅读:
    关于prototype学习
    java io 从文件的读取和输入
    java 匿名内部类
    动手做个 AI 机器人,帮我回消息!
    几个高效做事的法则,让你的一天有 25 小时
    爆肝一个月,我做了个免费的面试刷题网
    Log4j 被曝核弹级漏洞,开发者炸锅了!
    几个超火的编程网站,别错过!
    Java 处理表格,真的很爽!
    c++智能指针转化:static_pointer_cast、dynamic_pointer_cast、const_pointer_cast、reinterpret_pointer_cast
  • 原文地址:https://www.cnblogs.com/gwazy/p/111131.html
Copyright © 2011-2022 走看看