private void uiComboBox5_SelectedIndexChanged(object sender, EventArgs e) { this.menuSketch.Enabled = Janus.Windows.UI.InheritableBoolean.True; //for (int i = 0; i <= m_Map.LayerCount - 1; i++) //{ // if (uiComboBox5.SelectedIndex!=-1) // { // //if (m_Map.get_Layer(i).Name == uiComboBox5.SelectedItem.ToString()) // //{ // // m_CurrentLayer = m_Map.get_Layer(i); // // break; // //} // m_CurrentLayer = m_Map.get_Layer(i); // break; // } //} if (uiComboBox5.SelectedIndex!=-1) { m_CurrentLayer = m_Map.get_Layer(uiComboBox5.SelectedIndex); } if (m_bSketch) { CreatShape m_CreatShape = new CreatShape(m_CurrentLayer,this.m_dig); mapCtlMain.CurrentTool = (ITool)m_CreatShape; m_CreatShape.OnCreate(this.mapCtlMain.Object); } else if (m_bModify) { ModifyShape m_ModifyShape = new ModifyShape(m_CurrentLayer); mapCtlMain.CurrentTool = (ITool)m_ModifyShape; m_ModifyShape.OnCreate(this.mapCtlMain.Object); } }
private void uiCommandManager1_CommandClick(object sender, Janus.Windows.UI.CommandBars.CommandEventArgs e) { this.m_mapControl.CurrentTool = null; this.StatusBar.Panels[0].Text = "当前任务:" + e.Command.Text.ToString(); this.m_rasterMeasureDis = false; this.m_rasterMeasureArea = false; //this.mapCtlMain.CurrentTool = null; if (e.Command.Key == "menuExit") //退出程序 { Application.Exit(); } switch (e.Command.CategoryName) { #region 标准工具栏 case "Standard": m_toolLib.StandardToolLibrary(e.Command.Key.Substring(4, e.Command.Key.Length - 4)); break; #endregion #region 导航工具栏 case"Navigation": m_toolLib.NavigationToolLibrary(e.Command.Key.Substring(4, e.Command.Key.Length - 4)); break; #endregion 导航工具栏 #region 数据库工具栏 case "DB": m_toolLib.DBToolLibrary(e.Command.Key.Substring(4, e.Command.Key.Length - 4)); break; #endregion 数据库工具栏 #region 工具工具栏 case "Tool": m_toolLib.ToolToolLibrary(e.Command.Key.Substring(4, e.Command.Key.Length - 4)); break; #endregion 工具工具栏 case"CallMap": m_toolLib.CallMapToolLibrary(e.Command.Key.Substring(4, e.Command.Key.Length - 4)); break; case"3D": m_toolLib.ThreeDToolLibrary(e.Command.Key.Substring(4, e.Command.Key.Length - 4)); break; case"Index": m_toolLib.IndexToolibrry(e.Command.Key.Substring(4, e.Command.Key.Length - 4)); break; } #region 出图制图栏 if (e.Command.Key == "menuLegend") //设置比例尺 { DesignPageLayout designPageLayout = new DesignPageLayout(m_mapControl, m_pageLayoutControl); designPageLayout.AddLegend();//添加图例 } if (e.Command.Key == "menuText") { m_designPageLayout = new DesignPageLayout(m_mapControl, m_pageLayoutControl); m_designPageLayout.AddText();//添加文字 } if (e.Command.Key == "menuNorthArrow") { m_designPageLayout = new DesignPageLayout(m_mapControl, m_pageLayoutControl); m_designPageLayout.AddNorthArrow();//添加指北针 } if (e.Command.Key == "menuScaleBar") { m_designPageLayout = new DesignPageLayout(m_pageLayoutControl); m_designPageLayout.AddScaleBar();//添加比例尺 } if (e.Command.Key == "menuScaleText") { m_designPageLayout = new DesignPageLayout(m_pageLayoutControl); m_designPageLayout.AddTextScale();//添加文字比例尺 } if (e.Command.Key == "menuMapGrid") { m_designPageLayout = new DesignPageLayout(m_pageLayoutControl); m_designPageLayout.AddMapGrid();//添加地图格网 } if (e.Command.Key == "menuPageAndPrintaSet") { #region//页面设置 DialogResult result = pageSetupDialog1.ShowDialog(); document.PrinterSettings = pageSetupDialog1.PrinterSettings; document.DefaultPageSettings = pageSetupDialog1.PageSettings; int i; IEnumerator paperSizes = pageSetupDialog1.PrinterSettings.PaperSizes.GetEnumerator(); paperSizes.Reset(); for (i = 0; i < pageSetupDialog1.PrinterSettings.PaperSizes.Count; ++i) { paperSizes.MoveNext(); if (((PaperSize)paperSizes.Current).Kind == document.DefaultPageSettings.PaperSize.Kind) { document.DefaultPageSettings.PaperSize = ((PaperSize)paperSizes.Current); } } IPaper paper; paper = new PaperClass(); //create a paper object IPrinter printer; printer = new EmfPrinterClass(); //create a printer object paper.Attach(pageSetupDialog1.PrinterSettings.GetHdevmode(pageSetupDialog1.PageSettings).ToInt32(), pageSetupDialog1.PrinterSettings.GetHdevnames().ToInt32()); printer.Paper = paper; m_pageLayoutControl.Printer = printer; #endregion } if (e.Command.Key == "menuPrintView") { #region//打印预览 m_CurrentPrintPage = 0; if (axPageLayoutControl1.ActiveView.FocusMap == null) return; document.DocumentName = axPageLayoutControl1.DocumentFilename; printPreviewDialog1.Document = document; printPreviewDialog1.ShowDialog(); #endregion } if (e.Command.Key == "menuPrintExport") { #region //打印 //allow the user to choose the page range to be printed printDialog1.AllowSomePages = true; //show the help button. printDialog1.ShowHelp = true; //set the Document property to the PrintDocument for which the PrintPage Event //has been handled. To display the dialog, either this property or the //PrinterSettings property must be set printDialog1.Document = document; //show the print dialog and wait for user input DialogResult result = printDialog1.ShowDialog(); // If the result is OK then print the document. if (result == DialogResult.OK) document.Print(); #endregion } if (e.Command.Key == "menuPrintByAnyPolygonRegion") { if (this.mapCtlMain.LayerCount == 0) { MessageBox.Show("请先添加数据!", "提示"); return; } ICommand pArePrintMapClass = new ExportMapProj.AreaPrintMapClass(this.mapCtlMain.Map); pArePrintMapClass.OnCreate(this.mapCtlMain.Object); this.mapCtlMain.CurrentTool = (ITool)pArePrintMapClass; mapCtlMain.ActiveView.Refresh(); } if (e.Command.Key == "menuExportMap") { ICommand pExportMapAsPicture = new ExportMapProj.CmdExoprtMapAsPicture(); pExportMapAsPicture.OnCreate(m_pageLayoutControl.Object); pExportMapAsPicture.OnClick(); } #endregion #region 要素编辑 if (e.Command.Key == "menuStart") { if (mapCtlMain.LayerCount == 0) { MessageBox.Show("请先加载数据!"); return; } m_Map = mapCtlMain.Map; IFeatureLayer feaLayer = null; IDataset dataSet = null; IWorkspaceEdit wsEdit = null; for (int i = 0; i < m_Map.LayerCount; i++) { if (m_Map.get_Layer(i) is IFeatureLayer) { feaLayer = m_Map.get_Layer(i) as IFeatureLayer; dataSet = (IDataset)feaLayer.FeatureClass; wsEdit = dataSet.Workspace as IWorkspaceEdit; uiComboBox5.Items.Add(m_Map.get_Layer(i).Name); } if (wsEdit.IsBeingEdited()==true) { return; } } this.menuStart.Enabled = Janus.Windows.UI.InheritableBoolean.False; this.menuStop2.Enabled = Janus.Windows.UI.InheritableBoolean.True; this.menuSketch1.Enabled = Janus.Windows.UI.InheritableBoolean.True; this.menuSaveEditing2.Enabled = Janus.Windows.UI.InheritableBoolean.True; this.menuDelete1.Enabled = Janus.Windows.UI.InheritableBoolean.True; this.menuRedoEditing1.Enabled = Janus.Windows.UI.InheritableBoolean.True; this.menuUndoEditing1.Enabled = Janus.Windows.UI.InheritableBoolean.True; this.menuTask1.Enabled = Janus.Windows.UI.InheritableBoolean.True; this.menuLayer1.Enabled = Janus.Windows.UI.InheritableBoolean.True; uiComboBox5.SelectedIndex = 0; for (int i = 0; i < m_Map.LayerCount; i++) { if (m_Map.get_Layer(i).Name == uiComboBox5.Text) { m_CurrentLayer = m_Map.get_Layer(i); break; } } m_bModify = false; m_bSketch = true; uiComboBox4.SelectedIndex = 0; StartEditing(); MapEditing.CreatShape m_CreateShapeStart = new CreatShape(m_CurrentLayer,this.m_dig); mapCtlMain.CurrentTool = (ITool)m_CreateShapeStart; m_CreateShapeStart.OnCreate(this.mapCtlMain.Object); } if (e.Command.Key == "menuStop") { if (mapCtlMain.LayerCount == 0) { MessageBox.Show("请加载数据!"); return; } if (StopEditing() == 1) { mapCtlMain.Map.ClearSelection(); mapCtlMain.ActiveView.Refresh(); mapCtlMain.MousePointer = esriControlsMousePointer.esriPointerDefault; this.menuStart.Enabled = Janus.Windows.UI.InheritableBoolean.True; this.menuStop2.Enabled = Janus.Windows.UI.InheritableBoolean.False; this.menuSketch1.Enabled = Janus.Windows.UI.InheritableBoolean.False; this.menuSaveEditing2.Enabled = Janus.Windows.UI.InheritableBoolean.False; this.uiComboBox4.Text = ""; this.uiComboBox5.Text =""; this.menuDelete1.Enabled = Janus.Windows.UI.InheritableBoolean.False; this.menuRedoEditing1.Enabled = Janus.Windows.UI.InheritableBoolean.False; this.menuUndoEditing1.Enabled = Janus.Windows.UI.InheritableBoolean.False; this.menuTask1.Enabled = Janus.Windows.UI.InheritableBoolean.False; this.menuLayer1.Enabled = Janus.Windows.UI.InheritableBoolean.False; this.uiComboBox5.Items.Clear(); } } if (e.Command.Key == "menuSaveEditing") { if (mapCtlMain.LayerCount == 0) { MessageBox.Show("请加载数据!"); return; } if (SaveEditing() == 1) { mapCtlMain.Map.ClearSelection(); mapCtlMain.ActiveView.Refresh(); } } if (e.Command.Key == "menuSketch") //草图画笔工具 { if (mapCtlMain.LayerCount == 0) { MessageBox.Show("请加载数据!"); return; } if (m_bSketch) { CreatShape m_CreateShapeSketch = new CreatShape(m_CurrentLayer,this.m_dig); mapCtlMain.CurrentTool = (ITool)m_CreateShapeSketch; m_CreateShapeSketch.OnCreate(this.mapCtlMain.Object); } else if (m_bModify) { ModifyShape m_ModifyShape = new ModifyShape(m_CurrentLayer); mapCtlMain.CurrentTool = (ITool)m_ModifyShape; m_ModifyShape.OnCreate(this.mapCtlMain.Object); } else if (m_bEditNode) { } else { MessageBox.Show("编辑操作尚未开始,请先开始编辑!"); return; } StartEditing();//开始编辑 } if (e.Command.Key == "menuDelete") { if (mapCtlMain.LayerCount == 0) { MessageBox.Show("请先加载数据!"); return; } DeleteSelectedFeatures(); //调用删除要素方法 } if (e.Command.Key == "menuUndoEditing") { if (m_CurrentLayer == null) return; IWorkspaceEdit pWorkSpaceEdit = GetWorkspaceEdit(); bool bHasUndos = false; pWorkSpaceEdit.HasUndos(ref bHasUndos); if (bHasUndos) pWorkSpaceEdit.UndoEditOperation(); IActiveView pActiveView = m_Map as IActiveView; pActiveView.Refresh(); } if (e.Command.Key == "menuRedoEditing") { if (m_CurrentLayer == null) return; IWorkspaceEdit pWorkSpaceEdit = GetWorkspaceEdit(); bool bHasRedo = false; pWorkSpaceEdit.HasRedos(ref bHasRedo); if (bHasRedo) pWorkSpaceEdit.RedoEditOperation(); IActiveView pActiveView = m_Map as IActiveView; pActiveView.Refresh(); } #endregion if (e.Command.Key == "menuSelectbyAttribute") { if (this.mapCtlMain.LayerCount == 0) { MessageBox.Show("请先添加数据!"); return; } QueryForm pQueryForm = new QueryForm(this.m_mapControl); pQueryForm.Show(); } if (e.Command.Key == "menuSelectbyLocation") { if (this.mapCtlMain.LayerCount == 0) { MessageBox.Show("请先添加数据!"); return; } SpatialQueryForm pSpatialQueryForm = new SpatialQueryForm(this.m_mapControl); pSpatialQueryForm.Show(); } if (e.Command.Key == "menuBuffer") { if (this.mapCtlMain.LayerCount == 0) { MessageBox.Show("请先添加数据!"); return; } BufferForm pBufferForm = new BufferForm(this.m_mapControl); pBufferForm.Show(); } if (e.Command.Key == "menuOverLay") { if (this.mapCtlMain.LayerCount == 0) { MessageBox.Show("请先添加数据!"); return; } OverLayerForm pOverLayerForm = new OverLayerForm(this.m_mapControl); pOverLayerForm.Show(); } if (e.Command.Key == "menu3DForm") { if (e.Command.Checked == Janus.Windows.UI.InheritableBoolean.False) { this.ThreeDtap.TabVisible = true; this.mapTab.Enabled = false; this.pageTab.Enabled = false; this.uiTab1.SelectedTab = this.ThreeDtap; this.ThreeDBar.Visible = true; e.Command.Checked = Janus.Windows.UI.InheritableBoolean.True; this.axTOCControl1.SetBuddyControl(this.axSceneControl1); } else { this.ThreeDtap.TabVisible = false; this.mapTab.Enabled = true; this.pageTab.Enabled = true; this.uiTab1.SelectedTab = this.mapTab; this.ThreeDBar.Visible = false; e.Command.Checked = Janus.Windows.UI.InheritableBoolean.False; this.axSceneControl1.CurrentTool = null; this.axSceneControl1.Scene.ClearLayers(); this.axTOCControl1.SetBuddyControl(this.mapCtlMain); } } if (e.Command.Key == "menuCacu") { if (this.mapCtlMain.LayerCount == 0) { MessageBox.Show("请先添加数据!"); return; } ICommand ff = new AreaPrintMapClass(); ff.OnCreate(this.m_mapControl); this.m_mapControl.CurrentTool = (ITool)ff; } if (e.Command.Key == "menuRasDis") { this.mapCtlMain.CurrentTool = null; bool isRaster = false; ILayer layer = null; for (int i = 0; i < this.mapCtlMain.LayerCount; i++) { layer = this.mapCtlMain.get_Layer(i); if (layer is IRasterLayer) { isRaster = true; break; } } if (isRaster == false) { MessageBox.Show("请先添加影像数据!", "提示"); return; } this.m_rasterMeasureDis = true; this.mapCtlMain.MousePointer = esriControlsMousePointer.esriPointerCrosshair; } if (e.Command.Key == "menuRasArea") { this.mapCtlMain.CurrentTool = null; bool isRaster = false; ILayer layer = null; for (int i = 0; i < this.mapCtlMain.LayerCount; i++) { layer = this.mapCtlMain.get_Layer(i); if (layer is IRasterLayer) { isRaster = true; break; } } if (isRaster == false) { MessageBox.Show("请先添加影像数据!", "提示"); return; } this.m_rasterMeasureArea = true; this.mapCtlMain.MousePointer = esriControlsMousePointer.esriPointerCrosshair; } if (e.Command.Key == "menuTemplate") { ChoseTemple chosetem = new ChoseTemple(); chosetem.ShowDialog(); if (chosetem.m_templateName != "") { this.axPageLayoutControl1.ActiveView.Clear(); if (chosetem.m_templateName.Contains("\\")) { this.axPageLayoutControl1.LoadMxFile(chosetem.m_templateName, Type.Missing); } else { this.axPageLayoutControl1.LoadMxFile(System.Windows.Forms.Application.StartupPath + @"\pagelayoutTemplate\" + chosetem.m_templateName, Type.Missing); } m_controlsSynchronizer.ReplaceMap(m_mapControl.Map);//重新联动 SetMapFrame(); m_pageLayoutControl.ActiveView.ShowScrollBars = true; } } if (e.Command.Key == "menuAbout") { frmAbout frmAbout = new frmAbout(); frmAbout.ShowDialog(); } if (e.Command.Key == "menuTOCControl") { if (this.menuTOCControl1.Checked == Janus.Windows.UI.InheritableBoolean.True) { this.TOCPanel.Visible = false; this.menuTOCControl1.Checked = Janus.Windows.UI.InheritableBoolean.False; } else { this.TOCPanel.Visible = true; this.menuTOCControl1.Checked = Janus.Windows.UI.InheritableBoolean.True; } } if (e.Command.Key == "menuAtrriWin") { if (this.menuAtrriWin1.Checked == Janus.Windows.UI.InheritableBoolean.True) { this.SearchPanel.Closed = true; this.menuAtrriWin1.Checked = Janus.Windows.UI.InheritableBoolean.False; } else { this.SearchPanel.Closed = false; this.menuAtrriWin1.Checked = Janus.Windows.UI.InheritableBoolean.True; } } if (e.Command.Key == "menuOut") { if (e.Command.Checked == Janus.Windows.UI.InheritableBoolean.True) { e.Command.Checked = Janus.Windows.UI.InheritableBoolean.False; m_out = false; } else { e.Command.Checked = Janus.Windows.UI.InheritableBoolean.True; m_out = true; this.mapCtlMain.ClearLayers(); IWorkspaceFactory workspaceFactory = new RasterWorkspaceFactory(); IWorkspace workspace; workspace = workspaceFactory.OpenFromFile(Application.StartupPath + "\\out", 0); //inPath栅格数据存储路径 IRasterWorkspace rastWork = (IRasterWorkspace)workspace; IRasterDataset rastDataset; rastDataset = rastWork.OpenRasterDataset("ps2010.img");//inName栅格文件名 IRasterLayer layer = new RasterLayerClass(); layer.CreateFromDataset(rastDataset); m_mapControl.AddLayer(layer, 0); m_mapControl.AddShapeFile(Application.StartupPath + "\\out", "WYDCZL.shp"); m_mapControl.ActiveView.Refresh(); } } if (e.Command.Key == "menuDig") { if (e.Command.Checked == Janus.Windows.UI.InheritableBoolean.False) { e.Command.Checked = Janus.Windows.UI.InheritableBoolean.True; this.m_dig = true; } else { e.Command.Checked = Janus.Windows.UI.InheritableBoolean.False; this.m_dig = false; } } if (e.Command.Key == "menuIndexCacu") { frmCacuIndex index = new frmCacuIndex(); index.ShowDialog(); } if (e.Command.Key == "menuSKC") { frmChart chart = new frmChart(this.m_oraCmd); chart.ShowDialog(); } //******************************增加----陈************************************************* //if (e.Command.Key == "menuKMEANS") //{ // KMEANS kMEANS = new KMEANS(m_mapControl); // kMEANS.ShowDialog(); //} //if (e.Command.Key == "menuCalibration") //{ // OpenFileDialog openGD = new OpenFileDialog(); // openGD.Filter = "ERDAS格式(*.img)|*.img|所有文件|*.*"; // if (openGD.ShowDialog() == DialogResult.OK) // { // string filename = openGD.FileName; // int bandCount; // try // { // IRasterLayer rasterLayer = new RasterLayerClass(); // rasterLayer.CreateFromFilePath(filename); // bandCount = rasterLayer.BandCount; // } // catch // { // MessageBox.Show("输入文件有误"); // return; // } // Calibration cali = new Calibration(filename, bandCount, m_mapControl); // cali.ShowDialog(); // } //} //if (e.Command.Key == "menuISODATA") //{ // ISODATA isodata = new ISODATA(m_mapControl); // isodata.ShowDialog(); //} //if (e.Command.Key == "menuNDVI") //{ // NDVI ndvi = new NDVI(m_mapControl); // ndvi.ShowDialog(); //} //if (e.Command.Key == "menuRVI") //{ // RVI rvi = new RVI(m_mapControl); // rvi.ShowDialog(); //} //if (e.Command.Key == "menuSAVI") //{ // SAVI savi = new SAVI(m_mapControl); // savi.ShowDialog(); //} //if (e.Command.Key == "menuVC") //{ // VegCover vegCover = new VegCover(m_mapControl); // vegCover.ShowDialog(); //} //if (e.Command.Key == "menuTemprature") //{ // Temperature temperature = new Temperature(m_mapControl); // temperature.ShowDialog(); //} //if (e.Command.Key == "menuChangeD") //{ // ChangeDetection changeD = new ChangeDetection(m_mapControl); // changeD.ShowDialog(); //} //if (e.Command.Key == "menuIce") //{ // IceExtract iceExtract = new IceExtract(m_mapControl); // iceExtract.ShowDialog(); //} //if (e.Command.Key == "menuWater") //{ // WaterExtract waterExtract = new WaterExtract(m_mapControl); // waterExtract.ShowDialog(); //} //if (e.Command.Key == "menuHOT") //{ // HOT hot = new HOT(m_mapControl); // hot.ShowDialog(); //} //if (e.Command.Key == "menuQAC") //{ // QAC qac = new QAC(m_mapControl); // qac.ShowDialog(); //} //if (e.Command.Key == "menuLUC") //{ // LandUseChange luc = new LandUseChange(m_mapControl); // luc.ShowDialog(); //} //if (e.Command.Key == "menuComposite") //{ // Composite comp = new Composite(m_mapControl); // comp.ShowDialog(); //} //***************************************************************************************** }
private void uiComboBox4_SelectedIndexChanged(object sender, EventArgs e) { // this.menuSketchTool.Enabled = Janus.Windows.UI.InheritableBoolean.True; mapCtlMain.MousePointer = esriControlsMousePointer.esriPointerDefault; m_bModify = false; m_bSketch = false; m_bEditNode = false; //选择编辑任务 switch (uiComboBox4.SelectedIndex) { case 0: mapCtlMain.MousePointer = esriControlsMousePointer.esriPointerPencil; m_bSketch = true; m_bModify = false; m_bEditNode = false; break; case 1: mapCtlMain.MousePointer = esriControlsMousePointer.esriPointerCrosshair; m_bModify = true; m_bSketch = false; m_bEditNode = false; break; case 2: mapCtlMain.MousePointer = esriControlsMousePointer.esriPointerCrosshair; m_bModify = false; m_bSketch = false; m_bEditNode = true; break; } if (m_bSketch) { CreatShape m_CreatShape = new CreatShape(m_CurrentLayer,this.m_dig); m_CreatShape.OnCreate(this.mapCtlMain.Object); mapCtlMain.CurrentTool = (ITool)m_CreatShape; } else if (m_bModify) { ModifyShape m_ModifyShape = new ModifyShape(m_CurrentLayer); m_ModifyShape.OnCreate(this.mapCtlMain.Object); mapCtlMain.CurrentTool = (ITool)m_ModifyShape; } else { mapCtlMain.CurrentTool = null; m_editor = new AoEditor(m_CurrentLayer, this.m_mapControl.Map); } }