www.pudn.com > MyVR.rar > MainForm.cs, change:2008-06-17,size:10857b


using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Text; 
using System.Windows.Forms; 
 
using ESRI.ArcGIS.SystemUI; 
using ESRI.ArcGIS.Carto; 
using ESRI.ArcGIS.Controls; 
using ESRI.ArcGIS.AnalysisTools; 
using ESRI.ArcGIS.Analyst3D; 
using ESRI.ArcGIS.esriSystem ; 
using ESRI.ArcGIS.DataSourcesFile; 
using ESRI.ArcGIS.DataSourcesGDB; 
using ESRI.ArcGIS.Output; 
using ESRI.ArcGIS.Geometry; 
using ESRI.ArcGIS.GeoDatabaseDistributed; 
using ESRI.ArcGIS.Geodatabase; 
using ESRI.ArcGIS.ReaderControl; 
 
 
 
namespace MyVR 
{ 
    public partial class MainForm : Form 
    { 
       public System.Windows.Forms.OpenFileDialog openFileDialog1;//1 
         
        public ISceneControl pSceneControl;//q1 
        public IScene pScene; 
 
        public int toolSelected = 0; 
         
        
        public MainForm() 
        { 
            InitializeComponent(); 
             
             
        } 
 
        private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) 
        { 
 
            switch (e.ClickedItem.Name) 
            { 
 
                case "ZoomIn": 
                    { 
                        ICommand command = new ControlsSceneZoomInTool();//ControlsSceneZoomInToolClass(); 
                        command.OnCreate(this.axSceneControl1.Object); 
                        this.axSceneControl1.CurrentTool = command as ESRI.ArcGIS.SystemUI.ITool; 
 
                    } 
                    break; 
                case "toolFly": 
                    { 
                        ICommand command = new ControlsSceneFlyToolClass();//ControlsSceneZoomInToolClass(); 
                        command.OnCreate(this.axSceneControl1.Object); 
                        this.axSceneControl1.CurrentTool = command as ESRI.ArcGIS.SystemUI.ITool; 
 
                    } 
                    break; 
 
                case "toolSelectFeatures": 
                    { 
                        ICommand command = new ControlsSceneSelectFeaturesToolClass();//ControlsSceneZoomInToolClass(); 
                        command.OnCreate(this.axSceneControl1.Object); 
                        this.axSceneControl1.CurrentTool = command as ESRI.ArcGIS.SystemUI.ITool; 
 
                    } 
                    break; 
 
                case "toolTargetZoom": 
                    { 
                        ICommand command = new ControlsSceneTargetZoomToolClass();//ControlsSceneZoomInToolClass(); 
                        command.OnCreate(this.axSceneControl1.Object); 
                        this.axSceneControl1.CurrentTool = command as ESRI.ArcGIS.SystemUI.ITool; 
 
                    } 
                    break; 
 
                case "toolFullExtent": 
                    { 
                        ICommand command = new ControlsSceneFullExtentCommandClass();//ControlsSceneZoomInToolClass(); 
                        command.OnCreate(this.axSceneControl1.Object); 
                        this.axSceneControl1.CurrentTool = command as ESRI.ArcGIS.SystemUI.ITool; 
 
                    } 
                    break; 
 
                    
                case "ZoomOut": 
                    { 
                        ICommand command = new ControlsSceneZoomOutTool(); 
                        command.OnCreate(this.axSceneControl1.Object); 
                        this.axSceneControl1.CurrentTool = command as ESRI.ArcGIS.SystemUI.ITool; 
                    } 
                    break; 
                case "Pan": 
                    { 
                        ICommand command = new ControlsScenePanTool(); 
                        command.OnCreate(this.axSceneControl1.Object); 
                        this.axSceneControl1.CurrentTool = command as ESRI.ArcGIS.SystemUI.ITool; 
                    } 
                    break; 
                case "Navigate": 
                    { 
                        ICommand command = new ControlsSceneNavigateTool(); 
                        command.OnCreate(this.axSceneControl1.Object); 
                        this.axSceneControl1.CurrentTool = command as ESRI.ArcGIS.SystemUI.ITool; 
                    } 
                    break; 
                case "QueryForm": 
                    { 
                        QueryForm qf = new QueryForm(pSceneControl);//q2 
                        qf.Show(); 
                    } 
                    break; 
                case "TableForm": 
                    { 
                        TableForm tf = new TableForm(); 
                        tf.Show(); 
                    } 
                    break; 
                case "AboutForm": 
                    { 
                        AboutForm af = new AboutForm(); 
                        af.Show(); 
                    } 
                    break; 
 
                case "identifyForm": 
                    { 
                        toolSelected = 1; 
                    } 
                    break; 
                case "btnClear": 
                    { 
                        axSceneControl1.Scene.ClearSelection(); 
                        //pSceneControl = (ISceneControl)axSceneControl1; 
                        //pScene = pSceneControl.SceneGraph.Scene; 
                        //pScene.ClearSelection(); 
                    } 
                    break; 
                default : 
                    break; 
            } 
        } 
 
        private void Zin_Click(object sender, EventArgs e) 
        { 
 
            ICommand command = new ControlsSceneZoomInTool();//ControlsSceneZoomInToolClass(); 
            command.OnCreate(this.axSceneControl1.Object); 
            this.axSceneControl1.CurrentTool = command as ESRI.ArcGIS.SystemUI.ITool; 
        } 
 
        private void zoomOutToolStripMenuItem_Click(object sender, EventArgs e) 
        { 
             ICommand command = new ControlsSceneZoomOutTool(); 
                        command.OnCreate(this.axSceneControl1.Object); 
                        this.axSceneControl1.CurrentTool = command as ESRI.ArcGIS.SystemUI.ITool; 
                    
        } 
 
       
 
        private void panToolStripMenuItem_Click(object sender, EventArgs e) 
        { 
            ICommand command = new ControlsScenePanToolClass();//ControlsScenePanTool(); 
            command.OnCreate(this.axSceneControl1.Object); 
            this.axSceneControl1.CurrentTool = command as ESRI.ArcGIS.SystemUI.ITool; 
        } 
 
        private void button1_Click(object sender, EventArgs e) 
        { 
            //ARLayer arLayer; 
             
            //EditProperties editOptions1 = new EditProperties(); 
            //editOptions1.ShowDialog(); 
        } 
 
        private void closeToolStripMenuItem_Click(object sender, EventArgs e) 
        { 
            this.Close(); 
        } 
 
        private void panToolStripMenuItem_Click_1(object sender, EventArgs e) 
        { 
            ICommand command = new ControlsScenePanToolClass();//ControlsScenePanTool(); 
            command.OnCreate(this.axSceneControl1.Object); 
            this.axSceneControl1.CurrentTool = command as ESRI.ArcGIS.SystemUI.ITool; 
        } 
 
        private void openToolStripMenuItem_Click(object sender, System.EventArgs e) 
        { 
        //    //openFileDialog1.Title = "Scene Documents"; 
        //    //openFileDialog1.DefaultExt = ".sxd"; 
        //    //openFileDialog1.Filter = "Scene Documents (*.sxd)|*.sxd|Scene Templates (*.sxt)|*.sxt"; 
        //    //openFileDialog1.ShowDialog(); 
        //   IWorkspaceFactory pWorkspaceFactory; 
        //    IFeatureWorkspace pFeatureWorkspace; 
        //    IFeatureLayer pFeatureLayer; 
        //    //获取当前路径和文件名 
        //    OpenFileDialog dlg = new OpenFileDialog(); 
        //    dlg.ShowDialog(); 
        //    string strFullPath = dlg.FileName; 
        //    if (strFullPath == "") return; 
        //    int Index = strFullPath.LastIndexOf("\\"); 
        //    string filePath = strFullPath.Substring(0, Index); 
        //    string fileName = strFullPath.Substring(Index + 1); 
        //    //打开工作空间并添加shp文件 
        //    pWorkspaceFactory = new ShapefileWorkspaceFactoryClass(); 
        //    //注意此处的路径是不能带文件名的 
        //    pFeatureWorkspace = (IFeatureWorkspace)pWorkspaceFactory.OpenFromFile(filePath, 0); 
        //    pFeatureLayer = new FeatureLayerClass(); 
        //    //注意这里的文件名是不能带路径的 
        //    pFeatureLayer.FeatureClass = pFeatureWorkspace.OpenFeatureClass(fileName); 
        //    pFeatureLayer.Name = pFeatureLayer.FeatureClass.AliasName; 
        //    axSceneControl1.Scene.AddLayer(pFeatureLayer, false); 
        //    axSceneControl1.SceneGraph.RefreshViewers(); 
            openFileDialog1.Title = "打开"; 
            openFileDialog1.Filter = "ArcScene documents(*.sxd)|*.sxd"; 
            openFileDialog1.ShowDialog(); 
            string sFilePath = openFileDialog1.FileName; 
            if (sFilePath == "") 
                return; 
            axSceneControl1.LoadSxFile(sFilePath); 
            
 
        } 
 
        private void aboutToolStripMenuItem_Click(object sender, EventArgs e) 
        { 
            //axSceneControl1.AboutBox(); 
            AboutForm a = new AboutForm(); 
            a.Show(); 
        } 
 
        private void MainForm_Load(object sender, EventArgs e) 
        { 
            pSceneControl = (ISceneControl)axSceneControl1.Object; 
            //this.Visible = false; 
            //login lg = new login(); 
            //lg.Show(); 
                 
        } 
 
        private void axSceneControl1_OnMouseDown(object sender, ISceneControlEvents_OnMouseDownEvent e) 
       { 
        //     private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) 
        //{ 
        //    //if (e.button == 1 && toolSelected==true) 
        //    //{ 
        //    //    X1 = e.mapX; 
        //    //    Y1 = e.mapY; 
        //    //} 
 
            if (e.button == 1 && toolSelected == 1) 
            { 
               //// IEnvelope pEnvelop = pSceneControl.TrackRectangle(); 
               // IEnvelope pEnvelop = null ; 
               // pSceneControl.Scene .ClearSelection(); 
               // QueryInfomation fProperty = new QueryInfomation(pSceneControl, pEnvelop); 
               // fProperty.Show(); 
 
                 
            } 
 
 
 
        } 
 
        //private void axTOCControl1_OnMouseDown(object sender, System .EventArgs e) 
        //{ 
        //    openFileDialog1.Title = "打开"; 
        //    openFileDialog1.Filter = "ArcMap documents(*.mxd)|*.mxd"; 
        //    openFileDialog1.ShowDialog(); 
        //} 
     
          
    } 
}