Beispiel #1
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add AddNetStopsTool.OnMouseDown implementation
            try
            {
                IFeature newPointFeature = inputFClass.CreateFeature();
                IPoint   pStopsPoint     = new PointClass();
                pStopsPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

                try
                {
                    pStopsPoint.Z         = 0;
                    newPointFeature.Shape = pStopsPoint;
                    IZAware pZAware = pStopsPoint as IZAware;
                    IMAware pMAware = pStopsPoint as IMAware;
                    pZAware.ZAware = true;
                    pMAware.MAware = true;
                }
                catch
                {
                    IGeometry pGeo    = pStopsPoint;
                    IZAware   pZAware = pGeo as IZAware;
                    pZAware.ZAware = false;

                    newPointFeature.Shape = pGeo;
                }
                newPointFeature.Store();
                IGraphicsContainer pGrap = m_hookHelper.ActiveView as IGraphicsContainer;
                IColor             pColor;
                IRgbColor          pRgbColor = new RgbColorClass();
                pRgbColor.Red   = 255;
                pRgbColor.Green = 255;
                pRgbColor.Blue  = 255;
                pColor          = pRgbColor as IColor;
                IPictureMarkerSymbol pms = new PictureMarkerSymbolClass();
                pms.BitmapTransparencyColor = pColor;
                string picturePath = NetWorkAnalysClass.getPath(path) + "\\Img\\stops.bmp";
                //添加自定义站点图片
                pms.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, picturePath);
                pms.Size = 18;
                IMarkerElement pMarkerEle = new MarkerElementClass();
                pMarkerEle.Symbol            = pms as IMarkerSymbol;
                pStopsPoint.SpatialReference = m_hookHelper.ActiveView.FocusMap.SpatialReference;
                IElement pEle = pMarkerEle as IElement;
                pEle.Geometry = pStopsPoint;
                pGrap.AddElement(pEle, 1);
                m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            }
            catch
            {
                MessageBox.Show("添加站点失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Occurs when this tool is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add AddNetBarriesTool.OnClick implementation
            string name = NetWorkAnalysClass.getPath(path) + "\\HuanbaoGeodatabase.gdb";

            pFWorkspace   = NetWorkAnalysClass.OpenWorkspace(name) as IFeatureWorkspace;
            barriesFClass = pFWorkspace.OpenFeatureClass("Barries");
            if (barriesFClass.FeatureCount(null) > 0)
            {
                ITable pTable = barriesFClass as ITable;
                pTable.DeleteSearchedRows(null);
            }
        }
Beispiel #3
0
 //清除分析
 private void clear_Click(object sender, EventArgs e)
 {
     mainMapControl.CurrentTool = null;
     try
     {
         string name = NetWorkAnalysClass.getPath(path) + "\\HuanbaoGeodatabase.gdb";
         //打开工作空间
         pFWorkspace = NetWorkAnalysClass.OpenWorkspace(name) as IFeatureWorkspace;
         IGraphicsContainer pGrap = this.mainMapControl.ActiveView as IGraphicsContainer;
         pGrap.DeleteAllElements();//删除所添加的图片要素
         IFeatureClass inputFClass = pFWorkspace.OpenFeatureClass("Stops");
         //删除站点要素
         if (inputFClass.FeatureCount(null) > 0)
         {
             ITable pTable = inputFClass as ITable;
             pTable.DeleteSearchedRows(null);
         }
         IFeatureClass barriesFClass = pFWorkspace.OpenFeatureClass("Barries");//删除障碍点要素
         if (barriesFClass.FeatureCount(null) > 0)
         {
             ITable pTable = barriesFClass as ITable;
             pTable.DeleteSearchedRows(null);
         }
         for (int i = 0; i < mainMapControl.LayerCount; i++)//删除分析结果
         {
             ILayer pLayer = mainMapControl.get_Layer(i);
             if (pLayer.Name == ShortPathSolveCommand.m_NAContext.Solver.DisplayName)
             {
                 mainMapControl.DeleteLayer(i);
                 break;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     this.mainMapControl.Refresh();
 }