Exemple #1
0
        /// <summary>
        /// Occurs when this tool is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add AddNetBarriesTool.OnClick implementation
            string name = NetWorkAnalysClass.getPath(path) + "\\data\\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);
            }
        }
Exemple #2
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add AddNetBarriesTool.OnMouseDown implementation
            try
            {
                IPoint pStopsPoint = new PointClass();
                pStopsPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

                IFeature newPointFeature = barriesFClass.CreateFeature();
                try
                {
                    newPointFeature.Shape = pStopsPoint;
                }
                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;
                //添加自定义障碍点图片
                pms.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, NetWorkAnalysClass.getPath(path) + "\\data\\Img\\barries.bmp");
                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;
            }
        }
Exemple #3
0
 private void barButtonItem39_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     axMapControl1.CurrentTool = null;
     try
     {
         string name = NetWorkAnalysClass.getPath(path) + "\\data\\HuanbaoGeodatabase.gdb";
         //打开工作空间
         pFWorkspace = NetWorkAnalysClass.OpenWorkspace(name) as IFeatureWorkspace;
         IGraphicsContainer pGrap = this.axMapControl1.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 < axMapControl1.LayerCount; i++)//删除分析结果
         {
             ILayer pLayer = axMapControl1.get_Layer(i);
             if (pLayer.Name == ShortPathSolveCommand.m_NAContext.Solver.DisplayName)
             {
                 axMapControl1.DeleteLayer(i);
                 break;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     this.axMapControl1.Refresh();
 }