private void dataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e) { m_pCurFeature = null; if (e.Button == MouseButtons.Right && e.RowIndex >= 0 && e.RowIndex <= dataGridView1.Rows.Count) { m_nCurRowIndex = e.RowIndex; dataGridView1.Rows[m_nCurRowIndex].Selected = true; //contextMenuStrip1.Show(MousePosition.X, MousePosition.Y); m_pCurFeature = EngineFuntions.GetOneSeartchFeature(EngineFuntions.m_Layer_BusStation, "OBJECTID = " + dataGridView1.Rows[m_nCurRowIndex].Cells["OBJECTID"].Value.ToString()); } if (m_bEdit && e.Button == MouseButtons.Left && e.RowIndex >= 0 && e.RowIndex <= dataGridView1.Rows.Count) { if (e.ColumnIndex == dataGridView1.Columns["开始日期"].Index || e.ColumnIndex == dataGridView1.Columns["结束日期"].Index || e.ColumnIndex == dataGridView1.Columns["申请时间"].Index || e.ColumnIndex == dataGridView1.Columns["归档日期"].Index) { m_Rectangle = dataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true); //得到所在单元格位置和大小 m_dtp.Size = new Size(m_Rectangle.Width, m_Rectangle.Height); //把单元格大小赋给时间控件 m_dtp.Location = new System.Drawing.Point(m_Rectangle.X, m_Rectangle.Y); //把单元格位置赋给时间控件 m_dtp.Visible = true; //可以显示控件了 } else { m_dtp.Visible = false; } } }
private void dataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e) { m_pCurFeature = null; if (e.Button == MouseButtons.Right && e.RowIndex >= 0 && e.RowIndex <= dataGridView1.Rows.Count) { m_nCurRowIndex = e.RowIndex; dataGridView1.Rows[m_nCurRowIndex].Selected = true; contextMenuStrip1.Show(MousePosition.X, MousePosition.Y); m_pCurFeature = EngineFuntions.GetOneSeartchFeature(EngineFuntions.m_Layer_BusStation, "OBJECTID = " + dataGridView1.Rows[m_nCurRowIndex].Cells["OBJECTID"].Value.ToString()); } }
private void 定位到ToolStripMenuItem_Click(object sender, EventArgs e) { if (m_pCurFeature != null) { IEnvelope pEnvelope; pEnvelope = m_pCurFeature.Extent; pEnvelope.Expand(2, 2, true); EngineFuntions.m_AxMapControl.ActiveView.Extent = pEnvelope; EngineFuntions.m_AxMapControl.ActiveView.ScreenDisplay.Invalidate(null, true, (short)esriScreenCache.esriAllScreenCaches); System.Windows.Forms.Application.DoEvents(); EngineFuntions.FlashShape(m_pCurFeature.ShapeCopy); } }
private void button2_Click(object sender, EventArgs e) { List <IFeature> pFeatureList = new List <IFeature>(); List <IFeature> pCurFeatureList = EngineFuntions.GetSeartchFeatures(EngineFuntions.m_Layer_BusStation, "OBJECTID > -1"); foreach (IFeature pfeature in pCurFeatureList) { IFeatureLayer CurFeatureLayer = EngineFuntions.SetCanSelLay("道路中心线"); EngineFuntions.ClickSel(pfeature.ShapeCopy, false, true, 26); if (EngineFuntions.GetSeledFeatures(CurFeatureLayer, ref pFeatureList)) { foreach (IFeature pfea in pFeatureList) { int nIndex = pfeature.Fields.FindField("StationCharacter"); pfeature.set_Value(nIndex, pfea.get_Value(pfea.Fields.FindField("道路名称")) as string); } } pfeature.Store(); } MessageBox.Show("xxxxxx\n", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (m_bEdit) { m_nCurRowIndex = e.RowIndex; m_pCurFeature = EngineFuntions.GetOneSeartchFeature(EngineFuntions.m_Layer_BusStation, "OBJECTID = " + dataGridView1.Rows[m_nCurRowIndex].Cells["OBJECTID"].Value.ToString()); if (m_pCurFeature != null) { string strName = dataGridView1.Columns[e.ColumnIndex].Name; int nField = m_pCurFeature.Fields.FindField(strName); if (strName == "开始日期" || strName == "结束日期" || strName == "申请时间" || strName == "归档日期") { m_pCurFeature.set_Value(nField, Convert.ToDateTime(dataGridView1.Rows[m_nCurRowIndex].Cells[e.ColumnIndex].Value)); } else { m_pCurFeature.set_Value(nField, dataGridView1.Rows[m_nCurRowIndex].Cells[e.ColumnIndex].Value); } m_pCurFeature.Store(); } } }
private void dataGridView1_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { m_pCurFeature = null; if (e.RowIndex >= 0 && e.RowIndex <= dataGridView1.Rows.Count) { m_nCurRowIndex = e.RowIndex; dataGridView1.Rows[m_nCurRowIndex].Selected = true; m_pCurFeature = EngineFuntions.GetFeatureByFieldAndValue(EngineFuntions.m_Layer_BusStation, "OBJECTID", dataGridView1.Rows[m_nCurRowIndex].Cells["OBJECTID"].Value.ToString()); if (m_pCurFeature != null) { IEnvelope pEnvelope; pEnvelope = m_pCurFeature.Extent; pEnvelope.Expand(2, 2, true); EngineFuntions.m_AxMapControl.ActiveView.Extent = pEnvelope; EngineFuntions.m_AxMapControl.ActiveView.ScreenDisplay.Invalidate(null, true, (short)esriScreenCache.esriAllScreenCaches); System.Windows.Forms.Application.DoEvents(); EngineFuntions.FlashShape(m_pCurFeature.ShapeCopy); System.Windows.Forms.Application.DoEvents(); frmAttribute frmPopup = new frmAttribute(); frmPopup.m_featureCollection.Add(m_pCurFeature); frmPopup.ShowDialog(); } } }
private void frmMainNew_Load(object sender, EventArgs e) { EngineFuntions.m_AxMapControl = axMapControl1;//传递Map控件 axCommandBars1.LoadDesignerBars(null, null); axCommandBars1.ActiveMenuBar.Delete(); axCommandBars1.Options.UseDisabledIcons = true; UInt32 pColor; pColor = System.Convert.ToUInt32(ColorTranslator.ToOle(Color.FromArgb(255, 255, 255)).ToString()); axCommandBars1.SetSpecialColor((XtremeCommandBars.XTPColorManagerColor) 15, pColor); //m_pMapDocument = new MapDocumentClass(); //m_pMapDocument.Open("..\\..\\data\\DataSDE.mxd", string.Empty); //axMapControl1.Map = m_pMapDocument.get_Map(0); axMapControl1.Map.Name = "查询"; axMapControl1.Extent = axMapControl1.FullExtent; List <IFeatureLayer> colLayers; colLayers = EngineFuntions.GetAllValidFeatureLayers(axMapControl1.Map); //设置所有图层不能选择 EngineFuntions.SetCanSelLay("");//无图层名即所有不可选 EngineFuntions.m_Layer_BusStation = EngineFuntions.GetLayerByName("工程项目", colLayers); //EngineFuntions.m_Layer_BusRoad = EngineFuntions.GetLayerByName("公交站线", colLayers); //EngineFuntions.m_Layer_BackRoad = EngineFuntions.GetLayerByName("站线备份", colLayers); //Determine if Alpha Context is supported, if it is, then enable it axDockingPane1.Options.AlphaDockingContext = true; //Determine if Docking Stickers is supported, if they are, then enable them axDockingPane1.Options.ShowDockingContextStickers = true; axDockingPane1.Options.ThemedFloatingFrames = true; axDockingPane1.TabPaintManager.Position = XTPTabPosition.xtpTabPositionTop; axDockingPane1.TabPaintManager.Appearance = XtremeDockingPane.XTPTabAppearanceStyle.xtpTabAppearanceVisualStudio; XtremeDockingPane.Pane ThePane = axDockingPane1.CreatePane(ForAR.Pan_Layer, 200, 200, DockingDirection.DockLeftOf, null); ThePane.Title = "图层配置"; axDockingPane1.FindPane(ForAR.Pan_Layer).Handle = m_frmlayerToc.Handle.ToInt32(); ThePane = axDockingPane1.CreatePane(ForAR.Pan_Archive, 200, 200, DockingDirection.DockLeftOf, null); ThePane.Title = "工程入库"; axDockingPane1.FindPane(ForAR.Pan_Archive).Handle = m_frmArchivePane.Handle.ToInt32(); ThePane = axDockingPane1.CreatePane(ForAR.Pan_Query, 200, 200, DockingDirection.DockLeftOf, null); ThePane.Title = "工程查询"; axDockingPane1.FindPane(ForAR.Pan_Query).Handle = m_frmQueryPan.Handle.ToInt32(); axDockingPane1.AttachPane(axDockingPane1.FindPane(ForAR.Pan_Query), axDockingPane1.FindPane(ForAR.Pan_Archive)); axDockingPane1.AttachPane(axDockingPane1.FindPane(ForAR.Pan_Layer), axDockingPane1.FindPane(ForAR.Pan_Archive)); axDockingPane1.FindPane(ForAR.Pan_Layer).Select(); axDockingPane1.FindPane(ForAR.Pan_Query).Options = PaneOptions.PaneNoCloseable; axDockingPane1.FindPane(ForAR.Pan_Layer).Options = PaneOptions.PaneNoCloseable; axDockingPane1.FindPane(ForAR.Pan_Archive).Options = PaneOptions.PaneNoCloseable; //'鹰眼图: //String sHawkEyeFileName; //sHawkEyeFileName = ForAR.Mxd_Name; //m_frmlayerToc.MapHawkEye.LoadMxFile(sHawkEyeFileName); //m_frmlayerToc.MapHawkEye.Extent = m_frmlayerToc.MapHawkEye.FullExtent; //m_frmlayerToc.m_MapControl = axMapControl1.Object; m_frmlayerToc.TOCControl.SetBuddyControl(this.axMapControl1.Object); axDockingPane1.SetCommandBars(axCommandBars1.GetDispatch()); this.WindowState = FormWindowState.Maximized; m_bShowLayer = false; ForAR.m_FrmMain = this; if (ForAR.Login_Operation != "")//设置用户权限对应禁止的操作 { string[] strColu = ForAR.Login_Operation.Split(';'); int nCol; foreach (string eStrRow in strColu) { nCol = Convert.ToInt32(eStrRow[0].ToString()); string strRow = eStrRow.Substring(2); string[] strRows = strRow.Split('、'); foreach (string eStrRows in strRows) { axCommandBars1[nCol].Controls[Convert.ToInt32(eStrRows)].Enabled = false; } } } // Set what the Help file will be for the HelpProvider. this.helpProvider2.HelpNamespace = Winapp.StartupPath + @"\用户手册.doc"; }
private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { m_mapPoint = axMapControl1.ToMapPoint(e.x, e.y); IActiveView pActiveView = axMapControl1.ActiveView; if (e.button == 1) { switch (m_ToolStatus) { case ForAR.Map3D_Select: if (axMapControl1.Visible == true) { IGeometry pGeo; pGeo = axMapControl1.TrackRectangle(); if (pGeo.Envelope.Height * pGeo.Envelope.Width == 0) { return; } List <IFeature> pSelFea = EngineFuntions.GetSeartchFeatures(EngineFuntions.m_Layer_BusStation, pGeo); if (pSelFea.Count > 0) { frmAttribute frmPopup = new frmAttribute(); frmPopup.m_featureCollection = pSelFea; frmPopup.ShowDialog(); } } break; case ForAR.Map3D_PointSelect: if (axMapControl1.Visible == true) { m_CurFeatureLayer = EngineFuntions.SetCanSelLay("工程项目"); EngineFuntions.ClickSel(m_mapPoint, false, false, 6); if (EngineFuntions.GetSeledFeatures(m_CurFeatureLayer, ref m_featureCollection)) { frmAttribute frmPopup = new frmAttribute(); frmPopup.m_featureCollection = m_featureCollection; frmPopup.ShowDialog(); } } break; case ForAR.Map3D_PolySelect: if (axMapControl1.Visible == true) { IGeometry pGeo; pGeo = axMapControl1.TrackPolygon(); if (pGeo.Envelope.Height * pGeo.Envelope.Width == 0) { return; } List <IFeature> pSelFea = EngineFuntions.GetSeartchFeatures(EngineFuntions.m_Layer_BusStation, pGeo); if (pSelFea.Count > 0) { frmAttribute frmPopup = new frmAttribute(); frmPopup.m_featureCollection = pSelFea; frmPopup.ShowDialog(); } } break; case ForAR.Map3D_CircleSelect: if (axMapControl1.Visible == true) { IGeometry pGeo; pGeo = axMapControl1.TrackCircle(); if (pGeo.Envelope.Height * pGeo.Envelope.Width == 0) { return; } List <IFeature> pSelFea = EngineFuntions.GetSeartchFeatures(EngineFuntions.m_Layer_BusStation, pGeo); if (pSelFea.Count > 0) { frmAttribute frmPopup = new frmAttribute(); frmPopup.m_featureCollection = pSelFea; frmPopup.ShowDialog(); } } break; default: break; } } if (2 == e.button) { EngineFuntions.ZoomPoint(m_mapPoint, EngineFuntions.m_AxMapControl.Map.MapScale); } }
private void axCommandBars1_Execute(object sender, AxXtremeCommandBars._DCommandBarsEvents_ExecuteEvent e) { EngineFuntions.SetToolNull(); switch (e.control.Id) { //case ForAR.BusInfo_Help: // System.Diagnostics.Process.Start(Winapp.StartupPath + @"\用户手册.doc"); // break; //case ForAR.BusInfo_ParaSet: // System.Diagnostics.Process.Start(Winapp.StartupPath + @"\Businfo.ini"); // break; case ForAR.Map3D_ZoomIn: m_ToolStatus = ForAR.Map3D_ZoomIn; if (axMapControl1.Visible == true) { ICommand pCommand; pCommand = new ControlsMapZoomInTool(); pCommand.OnCreate(axMapControl1.Object); axMapControl1.CurrentTool = (ITool)pCommand; } break; case ForAR.Map3D_ZoomOut: m_ToolStatus = ForAR.Map3D_ZoomOut; if (axMapControl1.Visible == true) { ICommand pCommand; pCommand = new ControlsMapZoomOutTool(); pCommand.OnCreate(axMapControl1.Object); axMapControl1.CurrentTool = (ITool)pCommand; } break; case ForAR.Map3D_Pan: m_ToolStatus = ForAR.Map3D_Pan; if (axMapControl1.Visible == true) { ICommand pCommand; pCommand = new ControlsMapPanTool(); pCommand.OnCreate(axMapControl1.Object); axMapControl1.CurrentTool = (ITool)pCommand; } break; case ForAR.Map3D_Reflash: m_ToolStatus = ForAR.Map3D_Reflash; if (axMapControl1.Visible == true) { axMapControl1.Map.ClearSelection(); axMapControl1.ActiveView.GraphicsContainer.DeleteAllElements(); EngineFuntions.MapRefresh(); } break; //前一屏 case ForAR.Map3D_PreView: m_ToolStatus = ForAR.Map3D_PreView; if (axMapControl1.Visible == true) { EngineFuntions.GoBack(); } break; //后一屏 case ForAR.Map3D_NextView: m_ToolStatus = ForAR.Map3D_NextView; if (axMapControl1.Visible == true) { EngineFuntions.GoNext(); } break; case ForAR.Map3D_Distance: //计算长度 break; case ForAR.Map3D_Area: //计算面积 break; case ForAR.Map3D_Select: //拉框选择 m_ToolStatus = ForAR.Map3D_Select; axMapControl1.MousePointer = esriControlsMousePointer.esriPointerPencil; break; case ForAR.Map3D_PointSelect: //点击选择 m_ToolStatus = ForAR.Map3D_PointSelect; axMapControl1.MousePointer = esriControlsMousePointer.esriPointerPencil; break; case ForAR.Map3D_PolySelect: //多边形选择 m_ToolStatus = ForAR.Map3D_PolySelect; axMapControl1.MousePointer = esriControlsMousePointer.esriPointerPencil; break; case ForAR.Map3D_CircleSelect: //圆形选择 m_ToolStatus = ForAR.Map3D_CircleSelect; axMapControl1.MousePointer = esriControlsMousePointer.esriPointerPencil; break; case ForAR.Record_Input: //工程入库 m_ToolStatus = ForAR.Record_Input; axMapControl1.MousePointer = esriControlsMousePointer.esriPointerPencil; try { RegistryKey testKey = Registry.CurrentUser.OpenSubKey("TestKey"); if (testKey == null) { testKey = Registry.CurrentUser.CreateSubKey("TestKey"); testKey.SetValue("OpenFolderDir", ""); testKey.Close(); Registry.CurrentUser.Close(); } else { folderBrowserDialog1.SelectedPath = testKey.GetValue("OpenFolderDir").ToString(); testKey.Close(); Registry.CurrentUser.Close(); } } catch (Exception ee) { } if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { string folderName = folderBrowserDialog1.SelectedPath; m_frmArchivePane.m_FilePath.Clear(); m_frmArchivePane.m_strFolder = folderName; ForAR.FindFile(folderName + "\\", ref m_frmArchivePane.m_FilePath, folderName.LastIndexOf("\\") + 1); m_frmArchivePane.ReflashGrid(); axDockingPane1.FindPane(ForAR.Pan_Archive).Selected = true; RegistryKey testKey = Registry.CurrentUser.OpenSubKey("TestKey", true); //true表示可写,false表示只读 testKey.SetValue("OpenFolderDir", folderName); testKey.Close(); Registry.CurrentUser.Close(); } break; case ForAR.Map3D_Full: m_ToolStatus = ForAR.Map3D_Full; if (axMapControl1.Visible == true) { axMapControl1.Extent = axMapControl1.FullExtent; } break; default: break; } }
private void DWGLoad() { AcadApplication acadApp = new AcadApplicationClass(); IGeometryCollection pGeometryCollection = new PolygonClass(); foreach (DataGridViewRow eRow in dataGridView1.Rows) { if (eRow.Cells[0].Value != null && (bool)eRow.Cells[0].Value == true) { if (eRow.Cells["FileSuffix"].Value.ToString().ToLower() == "dwg") { object o = Type.Missing; string strFileName = eRow.Cells["FilePath"].Value.ToString(); AcadDocument acadDoc = acadApp.Documents.Open(strFileName, true, null); System.Windows.Forms.Application.DoEvents(); AcadLayer acadLyer = acadDoc.Layers.Item(1); AcadSelectionSet ssetObj = acadDoc.SelectionSets.Add("FWX"); short[] vFilterType = null; object[] vFilterData = null; vFilterType = new short[1]; vFilterType[0] = 8; vFilterData = new object[1]; vFilterData[0] = "FWX"; //ISegmentCollection pSegmentCollection = new RingClass(); //pSegmentCollection.AddSegment() ssetObj.Select(AcSelect.acSelectionSetAll, null, null, vFilterType, vFilterData); foreach (AcadObject eEntity in ssetObj) { if (eEntity.ObjectName == "AcDbPolyline") { AcadLWPolyline pPline = (AcadLWPolyline)eEntity; double[] polyLinePoint; polyLinePoint = (Double[])pPline.Coordinates; int i, pointCount = polyLinePoint.Length / 2; IPointCollection pPointColl = new RingClass(); for (i = 0; i < polyLinePoint.Length - 1; i = i + 2) { IPoint pPoint = new PointClass(); pPoint.X = polyLinePoint[i]; pPoint.Y = polyLinePoint[i + 1]; pPointColl.AddPoint(pPoint, ref o, ref o); } pGeometryCollection.AddGeometry(pPointColl as IRing, ref o, ref o); } } } else if (eRow.Cells["FileSuffix"].Value.ToString().ToLower() == "txt") { object o = Type.Missing; string strFileName = eRow.Cells["FilePath"].Value.ToString(); m_strPointArray.Clear(); StreamReader ReadFile = new StreamReader(strFileName, System.Text.Encoding.Default); while (!ReadFile.EndOfStream) { m_strPointArray.Add(ReadFile.ReadLine()); } ReadFile.Close(); IPointCollection pPointColl = new RingClass(); for (int i = 0; i < m_strPointArray.Count; i++) { if (m_strPointArray[i].StartsWith("J")) { string[] split = m_strPointArray[i].Split(new Char[] { ',', ',' }); IPoint pPoint = new PointClass(); pPoint.X = Convert.ToDouble(split[2]); pPoint.Y = Convert.ToDouble(split[3]); pPointColl.AddPoint(pPoint, ref o, ref o); } } pGeometryCollection.AddGeometry(pPointColl as IRing, ref o, ref o); } } } acadApp.Quit(); //DWGLoaded(this.m_Popfrm, new EventArgs());//引发完成事件,有异常待研究 System.Windows.Forms.Application.DoEvents(); if (pGeometryCollection.GeometryCount > 0) { m_pFeature = EngineFuntions.m_Layer_BusStation.FeatureClass.CreateFeature(); m_pFeature.Shape = pGeometryCollection as IPolygon; IFields fields = m_pFeature.Fields; int nIndex = fields.FindField("任务号"); m_pFeature.set_Value(nIndex, m_strFolder.Substring(m_strFolder.LastIndexOf("\\") + 1)); m_pFeature.Store(); EngineFuntions.ZoomTo(m_pFeature.ShapeCopy); } else { m_pFeature = null; } }