SoFunction
Updated on 2025-03-01

C#+MO implements a road editing software (just starting)

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

//****** main window program

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

using System;
using ;
using ;
using ;
using ;
using ;
using ;

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

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

            //AddFile(CD1, axMap1);
        }
//Delete the layer
        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            if ( >= 0)
            {
                for (int i = 0; i <=  - 1; i++)
                {
                    ();
                    break;
                }
                bool refTrue = true;
                ();
                (ref refTrue);
            }

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

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

        }

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

            if ( >= 0)
            {
                 layer= ( )( );
                 = ;
                 = ;                
            }
            (true, );
        }
//Zoom in
        private void tlb_ZoomIn_Click(object sender, EventArgs e)
        {
             = ;
        }
//Shrink
        private void tlb_ZoomOut_Click(object sender, EventArgs e)
        {
             = ;
        }
//roaming
        private void tlb_Pan_Click(object sender, EventArgs e)
        {
             = ;
        }
//Full picture
        private void tbl_Full_Click(object sender, EventArgs e)
        {
             = ;
             = ;
        }
//Gradually enlarge
        private void tbl_SmallIn_Click(object sender, EventArgs e)
        {
             r = ;
            (0.9);
             = r;
        }
//Gradually shrink
        private void tbl_SmallOut_Click(object sender, EventArgs e)
        {
             r = ;
            (1.1);
             = r;
        }
//Select query
        private void tbl_Identify_Click(object sender, EventArgs e)
        {
             = ;
        }
//Properties browsing
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            if ( >= 0 &  != null)
            {
                 lyr = ( )();
                IRND_DPT.frmBrowseAttr frmBrowset = new frmBrowseAttr();                
                (lyr);
                (this); 
            }
        }
// Map response event
        private void axMap1_MouseDownEvent(object sends, AxMapObjects2._DMapEvents_MouseDownEvent e)
        {
             rect;
             curp;
             lyr;
             rest;

            switch ()
            {
//Zoom in
                case :
                {                    
                    rect = ();
                    if ( == 0 ||  == 0)
                    {
                        rect = ;
                        (0.5);
                    }
                     = rect;
                    break;
                }
//Shrink
                case :
                {
                     Tempr;
                    Tempr = ;
                    rect = ();
                    double NewSR;
                    if ( != 0 ||  != 0)
                    {
                        if ( /   >  / )
                        {
                            NewSR =  / ;
                        }
                        else
                        {
                            NewSR =  / ;
                        }
                        (NewSR);
                    }
                    else 
                    {
                        (2.0);
                    }
                     = Tempr;
                    break;
                }
//roaming
                case :
                {
                    ();
                    break;
                }
//Select query
            case :
                {
                    if ( >= 0 &&  != "")
                    {
                        rect = ();
                        lyr = ()();
                        if ( == 0)
                        {
                            curp = (, );
                            rest = (curp, (double)((float) * 5), "");
                        }
                        else
                        {
                            rest = (rect, , "");
                        }
                        if (!=true)
                        {
                            (("shape").Value, 2);
                            IRND_DPT.frmIdentify FunctionClass = new frmIdentify();
                            ////();  
                            (rest);
                            (rest, );
                            (rest);
                            (this);
                        }
                    }
                    break;
                }
            }
        }


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

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

//************ Attribute query

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

using System;
using ;
using ;
using ;
using ;
using ;
using ;

namespace IRND_DPT
{
    public partial class frmIdentify : Form
    {
         mrs;        

        public frmIdentify()
        {
            InitializeComponent();
        }
        private void frmIdentify_Load(object sender,  e)
        {
             = ; 
("Field",50,);
("value",50,);

        }

        //


        private void tvFeat_NodeMouseClick(object sender,  e)
        {
            string ID;
            ListViewItem Item;

            //if ( == null) { return; }
            ();
            ID = ;
            ();
            while ( != true)
            {
                if (ID == ("FeatureID").ValueAsString)
                {
                    for (short fld = 1; fld < ; fld++)
                    {                        
                        Item = (.get_FieldName(fld));
                        (().ValueAsString);
                    }
                    ();   
                    break;
                }
                ();
            }     
        }

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

            ();
            if ( >= 2)
            {
                int i = 0;
                foreach (TreeNode tn in )
                {                    
                    i=i+1;
                    if (i == 2) 
                    { 
                        n = tn;
                        break;
                    }
                }              

                if ( != null)
                {
                    ();                    
                    ID = ("FeatureID").ValueAsString;                    
                    while ( != true)
                    {
                        if (ID == )
                        {
                            for (short fld = 1; fld < ; fld++)
                            {
                                Item = (.get_FieldName(fld));
                                (().ValueAsString);
                            }
                            ();
                            break;
                        }
                    }
                }
            }

        }
//Add the selected record set to the tree control for display
        public void IniTvFeat( moRs_in, string lyrName_in)
        {
            TreeNode n;            
            string ID;
            if (moRs_in.EOF != true)
            {
                moRs_in.MoveFirst();
                ();
                n = (lyrName_in);
                n=;
                while (moRs_in.EOF != true)
                {             
                    ID = moRs_in.("FeatureID").ValueAsString;                    
                    n= (ID);
                    moRs_in.MoveNext(); 
                }                  
            }
        }


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

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

//************Load layer function

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

using System;
using ;
using ;
using ;

namespace IRND_DPT
{
    class OpenFile
    {   
//Function description:
//                                                              �
        public void  OpenShapeFiles(OpenFileDialog comopenfile, map)
        {
            try
            {
                string strShape, strCov, strCAD, strVPF, strImage, strMilImage;


//Set the filter to a supported file
                strShape = "ESRI ShapeFiles(*.shp)|*.shp";
                strCov = "ESRI Coverages(*.adf,*.tat,*.pat,*.rat)|;;;;*.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";

                 = true;
//Set filtering
                 = strShape + "|" + strCov + "|" + strCAD + "|" + strImage ;
= "Add layer";
//Allow multiple files to select and long file names
                 = true;
                if (() == )
                {

                    foreach (string strFilename in )
                    {
                        string sPath = (0, ("\\") + 1);
                        string sFile = (("\\") + 1,  - ("\\") - 1);
                        string nametype = ((".") + 1,  - (".") - 1);
                        open_file(sPath, sFile, nametype, map);
                    }
                }
            }
            catch
            {
("There is an error in adding the layer!");
            }         
        }
//Function description:
//                                                              �
        private void open_file(string Path,string filename,string filetype, mapobject)
        {
            string LayerName = (0, ("."));
            switch (filetype)
            {
                case "shp":
                    shpAdd(Path, filename, mapobject, LayerName, true);
                    break;

            }
        }
//Function description:
//Add files in shape format
        public void   shpAdd(string databasepath, string filename, mapobject, string LayerName, bool Hide)
        { 
             dCon=new () ;
           //  gSet=new  ();
             newLayer = new ();     
            long i=0;

            try
            {
                 = databasepath;
                if (())
                {
                     gSet = (filename);
                    if (gSet == null)
                    {

                        return ;
                    }
                    else
                    { 
// Check whether there are duplicate layer names currently to ensure that all layer names are unique
                        if (FindMapLayerName(mapobject,LayerName)==true )
                        {
                            string tempstr = LayerName;
                            while (FindMapLayerName(mapobject, tempstr + "-" + i)==true )
                            {
                                i++;
                            }
                            LayerName = LayerName + "-" + i;
                        }
                         = gSet;

                        if (Hide)
                        {
                             = true;
                        }
                        else
                        {
                             = false; 
                        }
//Set the layer with default colors and styles
                        switch ()
                        { 
                            case  :
                                =11513775;
                                =5;
                                break;
                            case  .moShapeTypeLine :
                                 = 11513775;
                                 = 1;
                                break;
                            case  :
                                 = 0;
                                 = 8;
                                 = 12566463;
                                 = true;
                                 = (int);
                                break;
                        }
                         (newLayer);
                         = LayerName;
                        =databasepath + filename ;                        

                    }

                }
            }
            catch
            { 
// MessageBox("Error loading layer!");
            }
        }
//Function description:
//          Find layers in map mapobject,string LayerName
        public bool FindMapLayerName( mapobject, string LayerName)
        {    

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

                }
            }     
           return false ;

        }
    }
}