欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#+MO實現(xiàn)一個道路編輯軟件(剛開始)

 更新時間:2007年04月11日 00:00:00   作者:  
//**********************************************************

//******主窗口程序

//********************************************************

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

namespace IRND_DPT
{
    public partial class frmMain : Form
    {
        IRND_DPT.layerVariable pubLayerVariable = new layerVariable ();
        public frmMain()
        {
            InitializeComponent();
        }
        //添加圖層
        private void tlbAddLayer_Click(object sender, EventArgs e)
        {
            IRND_DPT.OpenFile AddFile = new OpenFile();
            AddFile.OpenShapeFiles(CD1,axMap1 );

            object refMap = (object)this.axMap1;
            bool refTrue = true;
            short refShort = 0;
            axlegend1.setMapSource(ref refMap);
            axlegend1.ShowAllLegend();
            axlegend1.LoadLegend(ref refTrue);
            axlegend1.set_Active(ref refShort, true);
            axMap1.Refresh();
            axlegend1.Refresh();

            //AddFile(CD1, axMap1);
        }
        //刪除圖層
        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            if (pubLayerVariable.MapLayerIndex >= 0)
            {
                for (int i = 0; i <= axMap1.Layers.Count - 1; i++)
                {
                    axMap1.Layers.Remove(pubLayerVariable.MapLayerIndex);
                    break;
                }
                bool refTrue = true;
                axMap1.Refresh();
                axlegend1.LoadLegend(ref refTrue);
            }

        }
        private void axlegend1_AfterSetLayerVisible(object sender,AxSampleLegendControl.__legend_AfterSetLayerVisibleEvent e)
        {
            axMap1.Refresh();            
        }

        private void axlegend1_LayerDblClick(object sender, AxSampleLegendControl.__legend_LayerDblClickEvent e)
        {

        }

        private void axlegend1_MouseDownEvent(object sender, AxSampleLegendControl.__legend_MouseDownEvent e)
        {

            if (e.index >= 0)
            {
                MapObjects2.MapLayer layer= (MapObjects2.MapLayer )axMap1.Layers.Item(e.index );
                pubLayerVariable.MapLayerName = layer.Name;
                pubLayerVariable.MapLayerIndex = e.index;                
            }
            axMap1.TrackingLayer.Refresh(true, axMap1.Extent);
        }
        //放大
        private void tlb_ZoomIn_Click(object sender, EventArgs e)
        {
            axMap1.MousePointer = MapObjects2.MousePointerConstants.moZoomIn;
        }
        //縮小
        private void tlb_ZoomOut_Click(object sender, EventArgs e)
        {
            axMap1.MousePointer = MapObjects2.MousePointerConstants.moZoomOut;
        }
        //漫游
        private void tlb_Pan_Click(object sender, EventArgs e)
        {
            axMap1.MousePointer = MapObjects2.MousePointerConstants.moPan;
        }
        //全圖
        private void tbl_Full_Click(object sender, EventArgs e)
        {
            axMap1.Extent = axMap1.FullExtent;
            axMap1.MousePointer = MapObjects2.MousePointerConstants.moArrow;
        }
        //逐漸放大
        private void tbl_SmallIn_Click(object sender, EventArgs e)
        {
            MapObjects2.Rectangle r = axMap1.Extent;
            r.ScaleRectangle(0.9);
            axMap1.Extent = r;
        }
        //逐漸縮小
        private void tbl_SmallOut_Click(object sender, EventArgs e)
        {
            MapObjects2.Rectangle r = axMap1.Extent;
            r.ScaleRectangle(1.1);
            axMap1.Extent = r;
        }
        //選擇查詢
        private void tbl_Identify_Click(object sender, EventArgs e)
        {
            axMap1.MousePointer = MapObjects2.MousePointerConstants.moIdentify;
        }
        //屬性瀏覽
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            if (pubLayerVariable.MapLayerIndex >= 0 & pubLayerVariable.MapLayerName != null)
            {
                MapObjects2.MapLayer lyr = (MapObjects2.MapLayer )axMap1.Layers.Item(pubLayerVariable.MapLayerName);
                IRND_DPT.frmBrowseAttr frmBrowset = new frmBrowseAttr();                
                frmBrowset.IniListview(lyr);
                frmBrowset.ShowDialog(this); 
            }
        }
        //地圖響應(yīng)事件
        private void axMap1_MouseDownEvent(object sends, AxMapObjects2._DMapEvents_MouseDownEvent e)
        {
            MapObjects2.Rectangle rect;
            MapObjects2.Point curp;
            MapObjects2.MapLayer lyr;
            MapObjects2.Recordset rest;

            switch (axMap1.MousePointer)
            {
                //放大                    
                case MapObjects2.MousePointerConstants.moZoomIn:
                {                    
                    rect = axMap1.TrackRectangle();
                    if (rect.Width == 0 || rect.Height == 0)
                    {
                        rect = axMap1.Extent;
                        rect.ScaleRectangle(0.5);
                    }
                    axMap1.Extent = rect;
                    break;
                }
                //縮小
                case MapObjects2.MousePointerConstants.moZoomOut:
                {
                    MapObjects2.Rectangle Tempr;
                    Tempr = axMap1.Extent;
                    rect = axMap1.TrackRectangle();
                    double NewSR;
                    if (rect.Width != 0 || rect.Height != 0)
                    {
                        if (axMap1.Extent.Width / rect.Width  > axMap1.Extent.Height / rect.Height)
                        {
                            NewSR = axMap1.Extent.Height / rect.Height;
                        }
                        else
                        {
                            NewSR = axMap1.Extent.Width / rect.Width;
                        }
                        Tempr.ScaleRectangle(NewSR);
                    }
                    else 
                    {
                        Tempr.ScaleRectangle(2.0);
                    }
                    axMap1.Extent = Tempr;
                    break;
                }
                //漫游
                case MapObjects2.MousePointerConstants.moPan:
                {
                    axMap1.Pan();
                    break;
                }
                //選擇查詢
            case MapObjects2.MousePointerConstants.moIdentify:
                {
                    if (pubLayerVariable.MapLayerIndex >= 0 && pubLayerVariable.MapLayerName != "")
                    {
                        rect = axMap1.TrackRectangle();
                        lyr = (MapObjects2.MapLayer)axMap1.Layers.Item(pubLayerVariable.MapLayerIndex);
                        if (rect.Width == 0)
                        {
                            curp = axMap1.ToMapPoint(e.x, e.y);
                            rest = lyr.SearchByDistance(curp, (double)axMap1.ToMapDistance((float)Screen.PrimaryScreen.WorkingArea.X * 5), "");
                        }
                        else
                        {
                            rest = lyr.SearchShape(rect, MapObjects2.SearchMethodConstants.moAreaIntersect, "");
                        }
                        if (rest.EOF!=true)
                        {
                            axMap1.FlashShape(rest.Fields.Item("shape").Value, 2);
                            IRND_DPT.frmIdentify FunctionClass = new frmIdentify();
                            ////FunctionClass.Close();  
                            FunctionClass.CurRecordSet(rest);
                            FunctionClass.IniTvFeat(rest, lyr.Name);
                            FunctionClass.IniLvwAttr(rest);
                            FunctionClass.Show(this);
                        }
                    }
                    break;
                }
            }
        }


        ////////
        ///////////////////////////////////////////////////////////////////////////////////////////////
    }
}

//*************************************************

//********屬性查詢

//************************************************

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

namespace IRND_DPT
{
    public partial class frmIdentify : Form
    {
        MapObjects2.Recordset mrs;        

        public frmIdentify()
        {
            InitializeComponent();
        }
        private void frmIdentify_Load(object sender, System.EventArgs e)
        {
            lvwAttr.View = View.Details; 
            lvwAttr.Columns.Add("字段",50,HorizontalAlignment.Left );
            lvwAttr.Columns.Add ("值",50,HorizontalAlignment.Center );

        }

        //


        private void tvFeat_NodeMouseClick(object sender, System.Windows.Forms.TreeNodeMouseClickEventArgs e)
        {
            string ID;
            ListViewItem Item;

            //if (e.Node.Parent == null) { return; }
            lvwAttr.Items.Clear();
            ID = e.Node.Text;
            mrs.MoveFirst();
            while (mrs.EOF != true)
            {
                if (ID == mrs.Fields.Item("FeatureID").ValueAsString)
                {
                    for (short fld = 1; fld < mrs.TableDesc.FieldCount; fld++)
                    {                        
                        Item = lvwAttr.Items.Add(mrs.TableDesc.get_FieldName(fld));
                        Item.SubItems.Add(mrs.Fields.Item(Item.Text).ValueAsString);
                    }
                    lvwAttr.Refresh();   
                    break;
                }
                mrs.MoveNext();
            }     
        }

        public void CurRecordSet(MapObjects2.Recordset vNewValue)
        {
            mrs = vNewValue;
        }
        public void IniLvwAttr(MapObjects2.Recordset rst)
        {
            TreeNode n=null ;
            ListViewItem Item;
            string ID;

            lvwAttr.Items.Clear();
            if (tvFeat.Nodes.Count >= 2)
            {
                int i = 0;
                foreach (TreeNode tn in tvFeat.Nodes)
                {                    
                    i=i+1;
                    if (i == 2) 
                    { 
                        n = tn;
                        break;
                    }
                }              

                if (n.Text != null)
                {
                    rst.MoveFirst();                    
                    ID = rst.Fields.Item("FeatureID").ValueAsString;                    
                    while (rst.EOF != true)
                    {
                        if (ID == n.Text)
                        {
                            for (short fld = 1; fld < rst.TableDesc.FieldCount; fld++)
                            {
                                Item = lvwAttr.Items.Add(rst.TableDesc.get_FieldName(fld));
                                Item.SubItems.Add(rst.Fields.Item(Item.Text).ValueAsString);
                            }
                            lvwAttr.Refresh();
                            break;
                        }
                    }
                }
            }

        }
        //將選擇的記錄集加入到樹型控件中進(jìn)行顯示
        public void IniTvFeat(MapObjects2.Recordset moRs_in, string lyrName_in)
        {
            TreeNode n;            
            string ID;
            if (moRs_in.EOF != true)
            {
                moRs_in.MoveFirst();
                tvFeat.Nodes.Clear();
                n = tvFeat.Nodes.Add(lyrName_in);
                n=n.Parent;
                while (moRs_in.EOF != true)
                {             
                    ID = moRs_in.Fields.Item("FeatureID").ValueAsString;                    
                    n= tvFeat.Nodes.Add(ID);
                    moRs_in.MoveNext(); 
                }                  
            }
        }


        ///////zuihou////////////////////////////////////////////////////////////////////////////
    }
}

//*************************************************************

//************加載圖層函數(shù)

//*************************************************************

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace IRND_DPT
{
    class OpenFile
    {   
        //功能說明:
        //    從公共對話框中提取文件名,然后調(diào)用不同的子模塊處理不同的文件加入圖層的問題(支持打開多個文件)
        public void  OpenShapeFiles(OpenFileDialog comopenfile,AxMapObjects2.AxMap map)
        {
            try
            {
                string strShape, strCov, strCAD, strVPF, strImage, strMilImage;


                //將過濾器設(shè)置為可支持的文件
                strShape = "ESRI ShapeFiles(*.shp)|*.shp";
                strCov = "ESRI Coverages(*.adf,*.tat,*.pat,*.rat)|aat.adf;pat.adf;nat.adf;txt.adf;*.tat;*.pat;*.rat";
                strCAD = "AutoCAD File (*.dwg,*.dxf)|*.dwg;*.dxf";
                strImage ="All Image(*.bmp,*.dib,*.tif,*.jpg,*.jff,*.bil,*.bip,*.bsq,*.gis,*.lan,*.rlc,*.sid,*.sun,*.rs,*.ras,*.svf,*.img,*.gif)|*.bmp,*.dib,*.tif,*.jpg,*.jff,*.bil,*.bip,*.bsq,*.gis,*.lan,*.rlc,*.sid,*.sun,*.rs,*.ras,*.svf,*.img,*.gif";

                comopenfile.CheckFileExists = true;
                //設(shè)置過濾
                comopenfile.Filter = strShape + "|" + strCov + "|" + strCAD + "|" + strImage ;
                comopenfile.Title = "添加圖層";
                //允許選擇多個文件,并允許長文件名
                comopenfile.Multiselect = true;
                if (comopenfile.ShowDialog() == DialogResult.OK)
                {

                    foreach (string strFilename in comopenfile.FileNames)
                    {
                        string sPath = strFilename.Substring(0, strFilename.LastIndexOf("\\") + 1);
                        string sFile = strFilename.Substring(strFilename.LastIndexOf("\\") + 1, strFilename.Length - strFilename.LastIndexOf("\\") - 1);
                        string nametype = sFile.Substring(sFile.LastIndexOf(".") + 1, sFile.Length - sFile.LastIndexOf(".") - 1);
                        open_file(sPath, sFile, nametype, map);
                    }
                }
            }
            catch
            {
                MessageBox.Show("圖層添加有錯!");
            }         
        }
        //功能說明:
        //    測試文件類型,一便調(diào)用不同的子模塊.處理不同圖層加入的問題
        private void open_file(string Path,string filename,string filetype,AxMapObjects2.AxMap mapobject)
        {
            string LayerName = filename.Substring(0, filename.LastIndexOf("."));
            switch (filetype)
            {
                case "shp":
                    shpAdd(Path, filename, mapobject, LayerName, true);
                    break;

            }
        }
        //功能說明:
        //添加shape格式的文件
        public void   shpAdd(string databasepath, string filename,AxMapObjects2.AxMap mapobject, string LayerName, bool Hide)
        { 
            MapObjects2.DataConnection dCon=new MapObjects2.DataConnection() ;
           // MapObjects2.GeoDataset gSet=new MapObjects2.GeoDataset ();
            MapObjects2.MapLayer newLayer = new MapObjects2.MapLayer();     
            long i=0;

            try
            {
                dCon.Database = databasepath;
                if (dCon.Connect())
                {
                    MapObjects2.GeoDataset gSet = dCon.FindGeoDataset(filename);
                    if (gSet == null)
                    {

                        return ;
                    }
                    else
                    { 
                        //查看當(dāng)前是否有重復(fù)的圖層名,以確保所有的圖層名都是唯一的
                        if (FindMapLayerName(mapobject,LayerName)==true )
                        {
                            string tempstr = LayerName;
                            while (FindMapLayerName(mapobject, tempstr + "-" + i)==true )
                            {
                                i++;
                            }
                            LayerName = LayerName + "-" + i;
                        }
                        newLayer.GeoDataset = gSet;

                        if (Hide)
                        {
                            newLayer.Visible = true;
                        }
                        else
                        {
                            newLayer.Visible = false; 
                        }
                        //使用默認(rèn)顏色和樣式設(shè)置圖層
                        switch (newLayer.shapeType)
                        { 
                            case MapObjects2.ShapeTypeConstants.moShapeTypePoint :
                                newLayer.Symbol.Color=11513775;
                                newLayer.Symbol.Size=5;
                                break;
                            case MapObjects2.ShapeTypeConstants .moShapeTypeLine :
                                newLayer.Symbol.Color = 11513775;
                                newLayer.Symbol.Size = 1;
                                break;
                            case MapObjects2.ShapeTypeConstants.moShapeTypePolygon :
                                newLayer.Symbol.SymbolType = 0;
                                newLayer.Symbol.Style = 8;
                                newLayer.Symbol.Color = 12566463;
                                newLayer.Symbol.Outline = true;
                                newLayer.Symbol.OutlineColor = (int)MapObjects2.ColorConstants.moBlack;
                                break;
                        }
                        mapobject.Layers.Add (newLayer);
                        newLayer.Name = LayerName;
                        newLayer.Tag=databasepath + filename ;                        

                    }

                }
            }
            catch
            { 
               // MessageBox("加載圖層出錯!");
            }
        }
        //功能說明:
        //    查找map中的圖層AxMapObjects2.AxMap mapobject,string LayerName 
        public bool FindMapLayerName(AxMapObjects2.AxMap mapobject, string LayerName)
        {    

            for (int i=0;i<mapobject.Layers.Count ;i++)
            {
                if (mapobject.Layers.Item(i).ToString() ==LayerName )
                {
                    return true;

                }
            }     
           return false ;

        }
    }
}

相關(guān)文章

  • C#讀取命令行參數(shù)的方法

    C#讀取命令行參數(shù)的方法

    這篇文章主要介紹了C#讀取命令行參數(shù)的方法,可實現(xiàn)讀取程序輸入命令行的所有參數(shù),便于調(diào)試程序,比較簡單實用,需要的朋友可以參考下
    2015-04-04
  • c#的treeview綁定和獲取值的方法

    c#的treeview綁定和獲取值的方法

    這篇文章主要介紹了c#的treeview綁定和獲取值的方法,需要的朋友可以參考下
    2014-04-04
  • C#進(jìn)制之間的相互轉(zhuǎn)換詳解

    C#進(jìn)制之間的相互轉(zhuǎn)換詳解

    關(guān)于進(jìn)制之間的相互轉(zhuǎn)換,很多人覺得進(jìn)制較多,所以轉(zhuǎn)換起來比較麻煩,筆者今天在這里說下,進(jìn)制雖然較多,但其實轉(zhuǎn)換的算法幾近相同
    2013-11-11
  • 深入c#繪制驗證碼的詳解

    深入c#繪制驗證碼的詳解

    本篇文章是對用c#繪制驗證碼的方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-06-06
  • C#彩色圖片灰度化算法實例

    C#彩色圖片灰度化算法實例

    這篇文章主要介紹了C#彩色圖片灰度化算法,以實例形式對灰度化算法進(jìn)行了較為詳細(xì)的介紹,非常具有實用價值,需要的朋友可以參考下
    2014-10-10
  • C# 實現(xiàn)QQ式截圖功能實例代碼

    C# 實現(xiàn)QQ式截圖功能實例代碼

    本篇文章主要介紹了C# 實現(xiàn)QQ式截圖功能實例代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-02-02
  • C#實現(xiàn)裝箱與拆箱操作簡單實例

    C#實現(xiàn)裝箱與拆箱操作簡單實例

    這篇文章主要介紹了C#實現(xiàn)裝箱與拆箱操作,對于新手理解裝箱與拆箱有一定的幫助,需要的朋友可以參考下
    2014-07-07
  • 10個C#程序員經(jīng)常用到的實用代碼片段

    10個C#程序員經(jīng)常用到的實用代碼片段

    如果你是一個C#程序員,那么本文介紹的10個C#常用代碼片段一定會給你帶來幫助,從底層的資源操作,到上層的UI應(yīng)用,這些代碼也許能給你的開發(fā)節(jié)省不少時間。以下是原文:
    2015-09-09
  • C#運行時相互關(guān)系淺析

    C#運行時相互關(guān)系淺析

    這篇文章介紹了C#運行時相互關(guān)系,包括運行時類型、對象、線程棧和托管堆之間的相互關(guān)系,靜態(tài)方法、實例方法和虛方法的區(qū)別等等。
    2015-10-10
  • C#設(shè)計模式之建造者模式

    C#設(shè)計模式之建造者模式

    這篇文章介紹了C#設(shè)計模式之建造者模式,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-07-07

最新評論