private static IPictureMarkerSymbol CreatePictureSymbol(string pictureName, int size)
        {
            IPictureMarkerSymbol pPicturemksb = new PictureMarkerSymbolClass();

            pPicturemksb.Size = size;
            string extension = System.IO.Path.GetExtension(pictureName);

            switch (extension)
            {
            case ".png":
                pPicturemksb.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG, pictureName);
                break;

            case ".jpg":
                pPicturemksb.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureJPG, pictureName);
                break;

            case ".gif":
                pPicturemksb.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureGIF, pictureName);
                break;

            case ".emf":
                pPicturemksb.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureEMF, pictureName);
                break;
            }
            return(pPicturemksb);
        }
Example #2
0
        /// <summary>
        /// 刷新Mobike数据
        /// </summary>
        public void RefreshmobikeInfo()
        {
            //获取车辆位置信息
            var mobikecars = new List <mobikeInfo>();

            NetUtils.GetmobikeCars(out mobikecars);
            if (mobikecars == null)
            {
                view.ShowError("数据出现问题,可能是mobike用户认证出错 返回示例数据");
                mobikecars = SampleData.mobikeSampleList;
            }

            IFeatureClass  featureclass  = CreateFeatureClass("mobike");
            IFeatureCursor featureCursor = featureclass.Insert(true);

            //遍历照片链表 以创建缓存的形式插入数据
            foreach (var c in mobikecars)
            {
                IPoint pPoint = new PointClass();
                //坐标转换
                var t = CoordinateUtils.gcj02_To_Wgs84(c.distY, c.distX);
                pPoint.PutCoords(t.longtitude, t.latitude);
                pPoint.SpatialReference = ApplicationV.GlobalMapControl.SpatialReference;
                pPoint.Project(ApplicationV.GlobalMapControl.SpatialReference);
                IFeatureBuffer featureBuffer = featureclass.CreateFeatureBuffer();
                featureBuffer.Shape = pPoint;
                featureBuffer.set_Value(featureBuffer.Fields.FindField("Latitude"), t.latitude);
                featureBuffer.set_Value(featureBuffer.Fields.FindField("Longtitude"), t.longtitude);
                featureCursor.InsertFeature(featureBuffer);
            }
            featureCursor.Flush();

            //创建图层
            IFeatureLayer pFeaturelayer = new FeatureLayerClass();

            pFeaturelayer.FeatureClass = featureclass;
            pFeaturelayer.Name         = "mobike分布";

            //修饰该图层
            IPictureMarkerSymbol mobikeMarkerSymbol = new PictureMarkerSymbolClass();

            mobikeMarkerSymbol.Size = 18;
            mobikeMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG, ApplicationV.Data_ImgPath + "//mobike.png");

//            ISimpleMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbol();
//            pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
//            var pRgbColor = ColorUtils.GetRgbColor(226, 61, 14);
//            pMarkerSymbol.Color = pRgbColor;

            ISimpleRenderer pSimpleRenderer = new SimpleRendererClass();

            pSimpleRenderer.Symbol = (ISymbol)mobikeMarkerSymbol;
            (pFeaturelayer as IGeoFeatureLayer).Renderer = pSimpleRenderer as IFeatureRenderer;

            //正式归为图层
            ofoLayer = pFeaturelayer as ILayer;

            ApplicationV.GlobalMapControl.AddLayer(ofoLayer);
            ApplicationV.GlobalMapControl.Refresh();
        }
Example #3
0
        private void ImagePointToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IFeatureLayer layer;

            layer = axMapControl1.get_Layer(0) as IFeatureLayer;          //QI到IGeoFeatureLayer
            IGeoFeatureLayer geoFeatureLayer = layer as IGeoFeatureLayer; //新建SimpleRendererClass对象
            SimpleRenderer   simpleRender    = new SimpleRendererClass(); //指定图片存放的位置
            OpenFileDialog   pOpenFileDialog = new OpenFileDialog
            {
                //Filter = "Image(*.img)|*.img",
                Title = "打开Image文件"
            };

            pOpenFileDialog.ShowDialog();
            string path = pOpenFileDialog.FileName;
            //string path = Application.StartupPath + @"\symbol\pointPic.BMP";
            IPictureMarkerSymbol pPictureMarkerSymbol = new PictureMarkerSymbolClass();

            pPictureMarkerSymbol.Size = 40;
            pPictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, path);
            simpleRender.Symbol      = pPictureMarkerSymbol as ISymbol;
            geoFeatureLayer.Renderer = simpleRender as IFeatureRenderer;
            axMapControl1.Refresh();
            axTOCControl1.Update();
        }
Example #4
0
        //更新车辆的位置
        private void MovePointUpdateElement(IPoint point)
        {
            try
            {
                IGraphicsContainer pGraphicsContainer = Variable.pMapFrm.mainMapControl.ActiveView as IGraphicsContainer;
                //pGraphicsContainer.DeleteAllElements();
                IMarkerElement pMarkerElement = new MarkerElementClass();
                //ISimpleMarkerSymbol来设置点的属性
                ISimpleMarkerSymbol pSymbol   = new SimpleMarkerSymbolClass();
                IRgbColor           pRGBcolor = new RgbColorClass();
                pRGBcolor.Red   = 255;
                pRGBcolor.Green = 0;
                pRGBcolor.Blue  = 0;

                IPictureMarkerSymbol pms = new PictureMarkerSymbolClass();
                pms.BitmapTransparencyColor = pRGBcolor;
                pms.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG, @"C:\Users\Administrator\Desktop\突发环境事件应急资源调度系统\DynamicSchedulingofEmergencyResourceSystem\DynamicSchedulingofEmergencyResourceSystem\Resources\vehicle.png");
                pms.Size = 6;
                pMarkerElement.Symbol = pms as IMarkerSymbol;

                //pSymbol.Color = pRGBcolor;
                //pMarkerElement.Symbol = pSymbol;
                Variable.PElement          = pMarkerElement as IElement;
                Variable.PElement.Geometry = point;
                pGraphicsContainer.AddElement(Variable.PElement, 0);
                //pGraphicsContainer.UpdateElement(Variable.PElement);
                //Variable.pMapFrm.mainMapControl.CenterAt(point);
                Variable.pMapFrm.mainMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                //Variable.pMapFrm.mainMapControl.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.ToString(), "异常");
            }
        }
Example #5
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add AddNetStopsTool.OnMouseDown implementation
            try
            {
                IPoint pStopsPoint = new PointClass();
                pStopsPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                IFeature newPointFeature = inputFClass.CreateFeature();
                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 = ApplicationV.Data_ImgPath + "\\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;
            }
        }
Example #6
0
 public override void OnMouseDown(int Button, int Shift, int X, int Y)
 {
     // TODO:  Add AddNetStopsTool.OnMouseDown implementation
     try
     {
         //根据人为用鼠标在地图上单击的点的坐标新建站点要素
         IPoint pStopsPoint = new PointClass();
         //将鼠标在屏幕上点击的一点的坐标转换为地图上的坐标,并赋给pStopsPoint
         pStopsPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
         IFeature newPointFeature = inputFClass.CreateFeature();//创建新的障碍点要素
         try
         {
             pStopsPoint.Z         = 0;
             newPointFeature.Shape = pStopsPoint;      //将pStopsPoint赋给新要素的Shape属性
             IZAware pZAware = pStopsPoint as IZAware; //Z值为高程
             IMAware pMAware = pStopsPoint as IMAware; //M值是用来储存其他属性信息,如温度、浓度
             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) + "\\data\\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;
     }
 }
Example #7
0
        private void btn2D_Click(object sender, EventArgs e)
        {
            try
            {
                IGraphicsContainer pGraphicsContainer = pPageLayoutControl.ActiveView.GraphicsContainer as IGraphicsContainer;
                IMarkerElement     pMarkerElement     = new MarkerElementClass();

                //////正北方向
                //IPictureMarkerSymbol pPMarkerNorth = new PictureMarkerSymbolClass();
                //string MarkerNorthPath = ClsGDBDataCommon.GetParentPathofExe() + @"Resource\BMP\NorthArrow.emf";
                //pPMarkerNorth.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureEMF, MarkerNorthPath);
                //pPMarkerNorth.Angle = 0;
                //pPMarkerNorth.Size = 100;

                ////太阳方向
                IPictureMarkerSymbol pPMarkerSun = new PictureMarkerSymbolClass();
                string MarkerSunPath             = ClsGDBDataCommon.GetParentPathofExe() + @"Resource\BMP\SunArrow.emf";
                pPMarkerSun.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureEMF, MarkerSunPath);
                pPMarkerSun.Angle = (-1) * SunAzimuth.Value;
                pPMarkerSun.Size  = 100;

                ////地球方向
                IPictureMarkerSymbol pPMarkerEarth = new PictureMarkerSymbolClass();
                string MarkerEarthPath             = ClsGDBDataCommon.GetParentPathofExe() + @"Resource\BMP\EarthArrow.emf";
                pPMarkerEarth.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureEMF, MarkerEarthPath);
                pPMarkerEarth.Angle = (-1) * EarAzimuth.Value;
                pPMarkerEarth.Size  = 100;


                IMultiLayerMarkerSymbol pMultiLayerMarkerSymbol = new MultiLayerMarkerSymbolClass();
                //pMultiLayerMarkerSymbol.AddLayer(pPMarkerNorth);
                pMultiLayerMarkerSymbol.AddLayer(pPMarkerSun);
                pMultiLayerMarkerSymbol.AddLayer(pPMarkerEarth);

                pMarkerElement.Symbol = pMultiLayerMarkerSymbol;
                IElement    pElement    = pMarkerElement as IElement;
                IActiveView pActiveView = pPageLayoutControl.ActiveView;
                IPageLayout pPageLayout = (IPageLayout)pActiveView;
                IPage       pPage       = pPageLayout.Page;
                double      pWidth      = pPage.PrintableBounds.XMin + 3;
                double      pHeigth     = pPage.PrintableBounds.YMax - 5;
                IPoint      pPoint      = new PointClass();
                pPoint.PutCoords(pWidth, pHeigth);
                pElement.Geometry = (IGeometry)pPoint;
                pGraphicsContainer.AddElement(pElement, 0);

                pPageLayoutControl.ActiveView.Refresh();
            }
            catch
            {
                MessageBox.Show(e.ToString());
            }

            this.Close();
        }
Example #8
0
        private IPictureMarkerSymbol creatpicpoint(double size, double xoffset, double yoffset, double angle, Color backcolor, string picfile)
        {
            IPictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbolClass();

            pictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, picfile);
            pictureMarkerSymbol.Size            = size;
            pictureMarkerSymbol.Angle           = angle;
            pictureMarkerSymbol.XOffset         = xoffset;
            pictureMarkerSymbol.YOffset         = yoffset;
            pictureMarkerSymbol.BackgroundColor = ClsGDBDataCommon.ColorToIColor(backcolor);
            return(pictureMarkerSymbol);
        }
Example #9
0
        private ISymbol CreateStandardLogoSymbol()
        {
            IPictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbolClass();

            pictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, m_logoPath);
            pictureMarkerSymbol.Size = 100;
            IColor whiteTransparencyColor = ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(255, 255, 255)) as IColor;

            pictureMarkerSymbol.BitmapTransparencyColor = whiteTransparencyColor;

            return(pictureMarkerSymbol as ISymbol);
        }
Example #10
0
        private static IPictureMarkerSymbol MakeMarkerSymbol(string renderPath, string icon, int size, int display, bool isVector)
        {
            esriIPictureType picType       = (isVector) ? esriIPictureType.esriIPictureEMF : esriIPictureType.esriIPicturePNG;
            string           extrafileName = (display == 2) ? "@2x" : "";
            string           suffix        = (picType == esriIPictureType.esriIPictureEMF) ? ".emf" : ".png";

            IPictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbolClass();

            pictureMarkerSymbol.CreateMarkerSymbolFromFile(picType, renderPath + "\\" + icon + "-" + size + extrafileName + suffix);
            pictureMarkerSymbol.Size = (((Double)size / 96.0) * 72.0); //so it is 1to1 at 96 dpi or twize that for retina
            return(pictureMarkerSymbol);
        }
Example #11
0
        /// <summary>
        /// 创建文本提示框
        /// </summary>
        /// <param name="x">提示框标识的位置X坐标</param>
        /// <param name="y">提示框标识的位置Y坐标</param>
        public void CreateTextElment(AxMapControl axMapControl1, double x, double y, string strText)
        {
            IPoint             pPoint      = new PointClass();
            IMap               pMap        = axMapControl1.Map;
            IActiveView        pActiveView = pMap as IActiveView;
            IGraphicsContainer pGraphicsContainer;
            IElement           pElement  = new MarkerElementClass();
            IElement           pTElement = new TextElementClass();

            pGraphicsContainer = (IGraphicsContainer)pActiveView;
            IFormattedTextSymbol pTextSymbol     = new TextSymbolClass();
            IBalloonCallout      pBalloonCallout = CreateBalloonCallout(x, y);
            IRgbColor            pColor          = new RgbColorClass();

            pColor.Red        = 150;
            pColor.Green      = 0;
            pColor.Blue       = 0;
            pTextSymbol.Color = pColor;
            ITextBackground pTextBackground;

            pTextBackground                  = (ITextBackground)pBalloonCallout;
            pTextSymbol.Background           = pTextBackground;
            ((ITextElement)pTElement).Symbol = pTextSymbol;
            ((ITextElement)pTElement).Text   = strText;

            IPoint p = new PointClass();

            //设置点的坐标
            p.PutCoords(x, y);
            IElementProperties   ipElemProp;
            IMarkerElement       ipMarkerElement = new MarkerElementClass();
            IPictureMarkerSymbol ipPicMarker     = new PictureMarkerSymbolClass();

            ipPicMarker.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, "D:\\pro\\ArcGisView\\ArcGisView\\1.bmp");
            ipPicMarker.Size = 24;
            IRgbColor ipRGBTrans = new RgbColorClass();

            ipRGBTrans.RGB = 0xffffff;
            ipPicMarker.BitmapTransparencyColor = ipRGBTrans as IColor;
            ipMarkerElement.Symbol = ipPicMarker as IMarkerSymbol;
            IElement ipElement = ipMarkerElement as IElement;

            ipElement.Geometry = p as IGeometry;
            axMapControl1.ActiveView.GraphicsContainer.AddElement(ipElement, 0);

            pPoint.X           = x + 42;
            pPoint.Y           = y + 42;
            pTElement.Geometry = pPoint;
            pGraphicsContainer.AddElement(pTElement, 1);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
        public static ISymbol GetPipSymbol(int sizeLayer, Color color)
        {
            var       size025  = sizeLayer;
            var       size05   = size025 * 2;
            var       size075  = size025 * 3;
            var       size     = size025 * 4;
            var       size15   = size025 * 6;
            var       size25   = size025 * 10;
            var       size275  = size025 * 11;
            var       size3    = size025 * 12;
            var       bitmap   = new Bitmap(size3, size3);
            const int sizeLine = 2;

            color = Color.FromArgb(255, color);

            using (Graphics ga = Graphics.FromImage(bitmap))
            {
                var points = new PointF[6];
                points[0] = new PointF(size05, size025);
                points[1] = new PointF(size25, size025);
                points[2] = new PointF(size15, size15);
                points[3] = new PointF(size25, size275);
                points[4] = new PointF(size05, size275);
                points[5] = new PointF(size15, size15);
                var pathd = new GraphicsPath();
                pathd.AddPolygon(points);
                ga.Clear(Color.White);
                ga.FillPath(Brushes.Yellow, pathd);
                ga.DrawPath(new Pen(Brushes.Gray, sizeLine), pathd);
                ga.DrawEllipse(new Pen(color, sizeLine), size, size, size, size);
                ga.FillEllipse(new SolidBrush(color), size, size, size, size);
                pathd.Dispose();
            }

            // ReSharper disable CSharpWarnings::CS0612
            // ReSharper disable CSharpWarnings::CS0618
            Bitmap bitmap8B  = bitmap.To8BppIndexed();
            string tempPath  = Path.GetTempPath();
            string writePath = Path.Combine(tempPath, string.Format("{0}pip.bmp", color.Name));

            bitmap8B.Save(writePath, ImageFormat.Bmp);
            IPictureMarkerSymbol symbol = new PictureMarkerSymbolClass();

            symbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, writePath);
            symbol.Size = size075;
            symbol.BitmapTransparencyColor = Converter.ToRGBColor(Color.White);
            return(symbol as ISymbol);
            // ReSharper restore CSharpWarnings::CS0618
            // ReSharper restore CSharpWarnings::CS0612
        }
        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;
            }
        }
Example #14
0
        //MultiLayerMarkerSymbol
        private void button5_Click(object sender, EventArgs e)
        {
            IMultiLayerMarkerSymbol multiLayerMarkerSymbol = new MultiLayerMarkerSymbolClass();
            IPictureMarkerSymbol    pictureMarkerSymbol    = new PictureMarkerSymbolClass();
            ICharacterMarkerSymbol  characterMarkerSymbol  = new CharacterMarkerSymbol();

            stdole.IFontDisp fontDisp = (stdole.IFontDisp)(new stdole.StdFontClass());
            IRgbColor        rgbColor = new RgbColor();

            rgbColor        = getRGB(0, 0, 0);
            fontDisp.Name   = "arial";
            fontDisp.Size   = 12;
            fontDisp.Italic = true;
            //创建字符符号
            characterMarkerSymbol.Angle          = 0;
            characterMarkerSymbol.CharacterIndex = 97;
            characterMarkerSymbol.Color          = rgbColor;
            characterMarkerSymbol.Font           = fontDisp;
            characterMarkerSymbol.Size           = 24;
            characterMarkerSymbol.XOffset        = 0;
            characterMarkerSymbol.YOffset        = 0;
            //创建图片符号
            //string fileName = @"E:\vs2005\第五章\lesson2\lesson2\data\qq.bmp";
            string path     = Directory.GetCurrentDirectory();
            string fileName = path + @"\qq.bmp";

            pictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, fileName);
            pictureMarkerSymbol.Angle = 0;
            pictureMarkerSymbol.BitmapTransparencyColor = rgbColor;
            pictureMarkerSymbol.Size    = 30;
            pictureMarkerSymbol.XOffset = 0;
            pictureMarkerSymbol.YOffset = 0;
            //添加图片、字符符号到组合符号中
            multiLayerMarkerSymbol.AddLayer(pictureMarkerSymbol);
            multiLayerMarkerSymbol.AddLayer(characterMarkerSymbol);
            multiLayerMarkerSymbol.Angle   = 0;
            multiLayerMarkerSymbol.Size    = 30;
            multiLayerMarkerSymbol.XOffset = 0;
            multiLayerMarkerSymbol.YOffset = 0;

            IPoint point1 = new PointClass();
            IPoint point2 = new PointClass();

            point1.PutCoords(5, 5);
            point2.PutCoords(5, 10);
            this.axMapControl1.FlashShape(point1 as IGeometry, 3, 200, multiLayerMarkerSymbol);
            this.axMapControl1.FlashShape(point2 as IGeometry);
        }
Example #15
0
        private static IPictureMarkerSymbol MakeMarkerSymbol(string filePath, double size)
        {
            if (!System.IO.File.Exists(filePath))
            {
                Console.WriteLine("Source MarkerSymbol does NOT exist: " + filePath);
                return(null);
            }

            bool             isVector = (filePath.Substring(filePath.Length - 4) == ".emf");
            esriIPictureType picType  = (isVector) ? esriIPictureType.esriIPictureEMF : esriIPictureType.esriIPicturePNG;

            IPictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbolClass();

            pictureMarkerSymbol.CreateMarkerSymbolFromFile(picType, filePath);
            pictureMarkerSymbol.Size = size;
            return(pictureMarkerSymbol);
        }
Example #16
0
        private void GetPipeInfo()
        {
            Load_LyrLstToArray();
            m_pArrPipes = new ArrayList();
            ISpatialFilter pSpatialFilter = new SpatialFilterClass();

            pSpatialFilter.Geometry    = pGeom;
            pSpatialFilter.WhereClause = fi.Name + "='消防栓'";
            pSpatialFilter.SpatialRel  = esriSpatialRelEnum.esriSpatialRelContains;

            for (int i = 0; i < m_pArrPointLayers.Count; i++)
            {
                pFeatureClass = (m_pArrPointLayers[i] as IFeatureLayer).FeatureClass;
                Console.WriteLine(pFeatureClass.AliasName);
                if (pFeatureClass.AliasName == "给水_点")
                {
                    pFeaCur = pFeatureClass.Search(pSpatialFilter, false);  //获得框选的消防栓的管点
                    pFea    = pFeaCur.NextFeature();
                    while (pFea != null)
                    {
                        m_pArrPipes.Add(pFea);
                        string Filename = Application.StartupPath + @"\..\Resource\Images\fireHydrant.png";
                        double mapX, mapY;
                        mapX = (pFea.Extent.XMax + pFea.Extent.XMin) / 2;
                        mapY = (pFea.Extent.YMax + pFea.Extent.YMin) / 2;
                        IPoint pPoint = new PointClass();
                        pPoint.PutCoords(mapX, mapY);
                        IPictureMarkerSymbol pPictureMarkerSymbol = new PictureMarkerSymbolClass();
                        pPictureMarkerSymbol.Size = 50;
                        pPictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG, Filename);
                        IMarkerElement pMarkerElement = new MarkerElementClass();
                        pMarkerElement.Symbol = pPictureMarkerSymbol as IMarkerSymbol;
                        IElement pElement = (IElement)pMarkerElement;
                        pElement.Geometry = pPoint;

                        this.m_pMapControl.ActiveView.GraphicsContainer.AddElement(pElement, 0);
                        this.m_pMapControl.FlashShape(pFea.Shape, 3, 500, null);
                        Console.WriteLine(pFea.OID);
                        pFea = pFeaCur.NextFeature();
                    }

                    break;
                }
            }
        }
 public override void OnMouseDown(int Button, int Shift, int X, int Y)
 {
     // TODO:  Add AddBarriesTool.OnMouseDown implementation
     try
     {
         IPoint pStopsPoint = new PointClass();
         pStopsPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
         IFeature newPointFeature = pFeatureClass.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.esriIPicturePNG, @"C:\Users\Administrator\Desktop\突发环境事件应急资源调度系统\DynamicSchedulingofEmergencyResourceSystem\DynamicSchedulingofEmergencyResourceSystem\Resources\barries.png");
         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 (Exception ex)
     {
         MessageBox.Show(ex.Message + "\n" + ex.ToString(), "异常");
     }
 }
        public void AddMarker(IPoint pt)
        {
            IPictureMarkerSymbol pPicturemksb = new PictureMarkerSymbolClass();

            pPicturemksb.Size = 20;
            string picturePath = getPath(path1) + "\\Image\\周边1.png";

            pPicturemksb.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG, picturePath);
            IMarkerElement pMarkerEle = new MarkerElement() as IMarkerElement;

            pMarkerEle.Symbol = pPicturemksb as IMarkerSymbol;
            IElement pEle = (IElement)pMarkerEle;

            pEle.Geometry = pt;
            IGraphicsContainer pGraphicsContainer = pActiveView.GraphicsContainer;

            pGraphicsContainer.AddElement(pEle, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
        public static ISymbol GetForbiddenSymbol(int sizeLayer, Color color)
        {
            var       size025   = sizeLayer;
            var       size075   = size025 * 3;
            var       size      = size025 * 4;
            var       size15    = size025 * 6;
            var       size175   = size025 * 7;
            var       size3     = size025 * 12;
            var       bitmap    = new Bitmap(size3, size3);
            const int sizeLine2 = 2;
            const int sizeLine3 = 3;
            const int sizeLine6 = 6;

            color = Color.FromArgb(255, color);

            using (Graphics ga = Graphics.FromImage(bitmap))
            {
                ga.Clear(Color.White);
                ga.DrawEllipse(new Pen(color, sizeLine2), size, size, size, size);
                ga.FillEllipse(new SolidBrush(color), size, size, size, size);
                ga.DrawEllipse(new Pen(Color.Red, sizeLine2), size15, size15, size075, size075);
                ga.FillEllipse(Brushes.Red, size15, size15, size075, size075);
                ga.DrawRectangle(new Pen(Color.WhiteSmoke, sizeLine2), size15 + sizeLine3, size175, size075 - sizeLine6, size025);
                ga.FillRectangle(Brushes.WhiteSmoke, size15 + sizeLine3, size175, size075 - sizeLine6, size025);
            }

            // ReSharper disable CSharpWarnings::CS0612
            // ReSharper disable CSharpWarnings::CS0618
            Bitmap bitmap8B  = bitmap.To8BppIndexed();
            string tempPath  = Path.GetTempPath();
            string writePath = Path.Combine(tempPath, string.Format("{0}forbidden.bmp", color.Name));

            bitmap8B.Save(writePath, ImageFormat.Bmp);
            IPictureMarkerSymbol symbol = new PictureMarkerSymbolClass();

            symbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, writePath);
            symbol.Size = size075;
            symbol.BitmapTransparencyColor = Converter.ToRGBColor(Color.White);
            return(symbol as ISymbol);
            // ReSharper restore CSharpWarnings::CS0618
            // ReSharper restore CSharpWarnings::CS0612
        }
Example #20
0
        /// <summary>
        /// 设置图片类型
        /// </summary>
        /// <param name="url"></param>
        private void SetPictureType(string url)
        {
            int    index   = url.LastIndexOf('.');
            int    count   = url.Length - 1 - index;
            string picType = url.Substring(index + 1, count).ToLower();

            switch (picType)
            {
            case "bmp":
                pictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, url);
                pictureType = esriIPictureType.esriIPictureBitmap;
                break;

            case "emf":
                pictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureEMF, url);
                pictureType = esriIPictureType.esriIPictureEMF;
                break;

            case "gif":
                pictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureGIF, url);
                pictureType = esriIPictureType.esriIPictureGIF;
                break;

            case "jpg":
                pictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureJPG, url);
                pictureType = esriIPictureType.esriIPictureJPG;
                break;

            case "jpeg":
                pictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureJPG, url);
                pictureType = esriIPictureType.esriIPictureJPG;
                break;

            case "png":
                pictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG, url);
                pictureType = esriIPictureType.esriIPicturePNG;
                break;
            }
        }
Example #21
0
        //图片符号化
        private void PictureMarkerSymbolToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                //获得点图层,要求当前地图文档第一个图层为点图层
                IFeatureLayer layer;
                layer = mainMapControl.get_Layer(0) as IFeatureLayer;
                //QI到IGeoFeatureLayer
                IGeoFeatureLayer geoFeatureLayer = layer as IGeoFeatureLayer;
                SimpleRenderer   simpleRender    = new SimpleRendererClass();
                //指定图片存放的位置
                //实例化OpenFileDialog控件
                OpenFileDialog pOpenFileDialog = new OpenFileDialog
                {
                    CheckFileExists  = true,
                    RestoreDirectory = true,
                    Title            = "选择图片"
                };

                if (pOpenFileDialog.ShowDialog() == DialogResult.OK)
                {
                    string path = pOpenFileDialog.FileName;
                    IPictureMarkerSymbol pPictureMarkerSymbol = new PictureMarkerSymbolClass();
                    pPictureMarkerSymbol.Size = 40;
                    pPictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, path);
                    simpleRender.Symbol      = pPictureMarkerSymbol as ISymbol;
                    geoFeatureLayer.Renderer = simpleRender as IFeatureRenderer;
                    mainMapControl.Refresh();
                    axTOCControl1.Update();
                }
            }
            catch
            {
                MessageBox.Show("没有可以实例化的图层");
            }
        }
Example #22
0
        /// <summary>
        /// 插入带图片的地图注记
        /// </summary>
        /// <param name="point"></param>
        /// <param name="mapControl"></param>
        /// <param name="pictureUri"></param>
        /// <returns></returns>

        public static IElement DrawSymbolWithPicture(IPoint point, AxMapControl mapControl, string pictureUri)
        {
            #region 注释
            //  IMap map = mapControl.Map;
            //  IEnvelope envelop = new EnvelopeClass();
            ////  point.QueryEnvelope(envelop);
            //   envelop.PutCoords(point.X - 50, point.Y - 50, point.X + 50, point.Y + 50);
            //  //实例化注记
            //  IPictureElement pictureElement = new PictureElementClass();
            //  pictureElement.MaintainAspectRatio = true;
            //  pictureElement.ImportPictureFromFile(pictureUri);
            //  IElement elment = pictureElement as IElement;
            //  elment.Geometry = envelop as IGeometry;
            //  //添加地图注记
            //  IGraphicsContainer graphicsContainer = map as IGraphicsContainer;
            //  graphicsContainer.AddElement(pictureElement as IElement, 0);
            //  (map as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, mapControl.Extent);
            #endregion
            IMap map = mapControl.Map;
            //实例化图片注记
            IPictureMarkerSymbol pPicturemksb = new PictureMarkerSymbolClass();
            pPicturemksb.Size = 20;
            pPicturemksb.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureJPG, pictureUri);
            //  Image image=Image.FromFile(pictureUri);
            // IPictureDisp pictureDisp= IPictureConverter.ImageToIPictureDisp(image);
            //  pPicturemksb.Picture = pictureDisp;
            IMarkerElement pMarkerEle = new MarkerElement() as IMarkerElement;
            //将注记添加到元素中
            pMarkerEle.Symbol = pPicturemksb as IMarkerSymbol;
            //添加元素到对应位置
            IElement pEle = (IElement)pMarkerEle;
            pEle.Geometry = point;
            //添加标注
            InsertElement(mapControl, pEle, 1);
            return(pEle);
        }
Example #23
0
        //PictureMarkerSymbol
        private void button4_Click(object sender, EventArgs e)
        {
            IRgbColor            rgbColor            = new RgbColorClass();
            IPictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbolClass();
            //string fileName = @"E:\vs2005\第五章\lesson2\lesson2\data\qq.bmp";

            string path     = Directory.GetCurrentDirectory();
            string fileName = path + @"\qq.bmp";

            pictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, fileName);
            pictureMarkerSymbol.Angle = 0;
            pictureMarkerSymbol.BitmapTransparencyColor = rgbColor;
            pictureMarkerSymbol.Size    = 20;
            pictureMarkerSymbol.XOffset = 0;
            pictureMarkerSymbol.YOffset = 0;
            IPoint point1 = new PointClass();
            IPoint point2 = new PointClass();

            point1.PutCoords(5, 5);
            point2.PutCoords(5, 10);

            this.axMapControl1.FlashShape(point1 as IGeometry, 3, 200, pictureMarkerSymbol);
            this.axMapControl1.FlashShape(point2 as IGeometry);
        }
        /// <summary>
        /// ����Ҫ�ط��Ż�
        /// </summary>
        /// <params name="layer"></params>
        /// <params name="field"></params>
        /// <params name="value"></params>
        /// <params name="pBitmap"></params>
        public static void SpecialPointRenderer(ILayer layer, string field, string value, Bitmap pBitmap)
        {
            IGeoFeatureLayer geoFeaLayer;
            IFeatureRenderer featureRenderer;
            ISymbol defaultSymbol;
            IUniqueValueRenderer uniValueRender;

            geoFeaLayer = layer as IGeoFeatureLayer;
            featureRenderer = geoFeaLayer.Renderer;
            uniValueRender = new UniqueValueRenderer();

            ///ѡ��ij���ֶ���Ϊ��Ⱦ����ֵ
            IQueryFilter2 queryFilter = new QueryFilterClass();
            int fieldIndex;
            uniValueRender.FieldCount = 1;
            uniValueRender.Field[0] = field;
            queryFilter.AddField(field);
            fieldIndex = geoFeaLayer.FeatureClass.Fields.FindField(field);//����ֶε�index

            ///��ȡ�Զ������
            ISymbol customSymbol;
            IPictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbolClass();
            pictureMarkerSymbol.Size = 55;
            string strFilePath = Application.StartupPath.ToString() + "\\temp.bmp";

            pBitmap.Save(strFilePath);
            pictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG,
              strFilePath);
            customSymbol = (ISymbol)pictureMarkerSymbol;

            ///������Ⱦ���Ž�����Ⱦ
            string sValue;
            IFeature feature = null;
            IFeatureCursor featureCursor;
            featureCursor = geoFeaLayer.FeatureClass.Search(queryFilter, true);
            feature = featureCursor.NextFeature();
            while (feature != null)
            {
                sValue = Convert.ToString(feature.get_Value(fieldIndex));
                if (sValue == value)
                {
                    uniValueRender.AddValue(sValue, "", customSymbol);
                }
                else
                {
                    ///�ǵ�ǰ��ѡҪ�أ�����ű��ֲ���
                    defaultSymbol = geoFeaLayer.Renderer.get_SymbolByFeature(feature);
                    uniValueRender.AddValue(sValue, "", defaultSymbol);
                }

                feature = featureCursor.NextFeature();
            }

            if (featureCursor != null)
            {
                featureCursor = null;
                ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(featureCursor);
            }

            geoFeaLayer.Renderer = uniValueRender as IFeatureRenderer;
        }
Example #25
0
        /// <summary>
        /// �����ı���ʾ��
        /// </summary>
        /// <param name="x">��ʾ���ʶ��λ��X����</param>
        /// <param name="y">��ʾ���ʶ��λ��Y����</param>
        public void CreateTextElment(AxMapControl axMapControl1, double x, double y, string strText)
        {
            IPoint pPoint = new PointClass();
            IMap pMap = axMapControl1.Map;
            IActiveView pActiveView = pMap as IActiveView;
            IGraphicsContainer pGraphicsContainer;
            IElement pElement = new MarkerElementClass();
            IElement pTElement = new TextElementClass();
            pGraphicsContainer = (IGraphicsContainer)pActiveView;
            IFormattedTextSymbol pTextSymbol = new TextSymbolClass();
            IBalloonCallout pBalloonCallout = CreateBalloonCallout(x, y);
            IRgbColor pColor = new RgbColorClass();
            pColor.Red = 150;
            pColor.Green = 0;
            pColor.Blue = 0;
            pTextSymbol.Color = pColor;
            ITextBackground pTextBackground;
            pTextBackground = (ITextBackground)pBalloonCallout;
            pTextSymbol.Background = pTextBackground;
            ((ITextElement)pTElement).Symbol = pTextSymbol;
            ((ITextElement)pTElement).Text = strText;

            IPoint p = new PointClass();
            //���õ������
            p.PutCoords(x, y);
            IElementProperties ipElemProp;
            IMarkerElement ipMarkerElement = new MarkerElementClass();
            IPictureMarkerSymbol ipPicMarker = new PictureMarkerSymbolClass();
            ipPicMarker.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, "D:\\pro\\ArcGisView\\ArcGisView\\1.bmp");
            ipPicMarker.Size = 24;
            IRgbColor ipRGBTrans = new RgbColorClass();
            ipRGBTrans.RGB = 0xffffff;
            ipPicMarker.BitmapTransparencyColor = ipRGBTrans as IColor;
            ipMarkerElement.Symbol = ipPicMarker as IMarkerSymbol;
            IElement ipElement = ipMarkerElement as IElement;
            ipElement.Geometry = p as IGeometry;
            axMapControl1.ActiveView.GraphicsContainer.AddElement(ipElement, 0);

            pPoint.X = x + 42;
            pPoint.Y = y + 42;
            pTElement.Geometry = pPoint;
            pGraphicsContainer.AddElement(pTElement, 1);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Example #26
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            try
            {
                IMap2DView mapView = UCService.GetContent(typeof(Map2DView)) as Map2DView;
                if (mapView == null)
                {
                    return;
                }
                if (app == null || app.Current2DMapControl == null || app.Workbench == null)
                {
                    return;
                }
                pGraphicsContainer.DeleteAllElements();
                app.Current2DMapControl.ActiveView.Refresh();

                IGeometry geo = app.Current2DMapControl.TrackCircle();
                if (geo != null)
                {
                    AddCircleElement(geo, this.m_ActiveView);
                    this.m_ActiveView.Refresh();
                }
                WaitForm.Start("正在查询...", "请稍后");
                FacilityClass facc = FacilityClassManager.Instance.GetFacilityClassByName("PipeNode");
                if (facc == null)
                {
                    return;
                }
                DFDataConfig.Class.FieldInfo fi = facc.GetFieldInfoBySystemName("Additional");
                if (fi == null)
                {
                    return;
                }

                string[] fc2d = facc.Fc2D.Split(';');
                foreach (string fcID in fc2d)
                {
                    DF2DFeatureClass dffc   = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fcID);
                    IFeatureClass    fctemp = dffc.GetFeatureClass();
                    if (fctemp.AliasName.Contains("上水"))
                    {
                        fc = fctemp;
                        break;
                    }
                }
                if (fc == null)
                {
                    return;
                }
                int index = fc.Fields.FindField(fi.Name);
                if (index == -1)
                {
                    return;
                }
                ISpatialFilter filter = new SpatialFilter();
                filter.SpatialRel  = esriSpatialRelEnum.esriSpatialRelIntersects;
                filter.Geometry    = geo;
                filter.WhereClause = fi.Name + "='" + "消火栓' OR " + fi.Name + "='" + "消防栓'";
                IFeatureCursor cursor = fc.Search(filter, false);
                int            count  = fc.FeatureCount(filter);
                if (count == 0)
                {
                    XtraMessageBox.Show("所选区域内无消防栓!"); WaitForm.Stop(); return;
                }
                while ((feature = cursor.NextFeature()) != null)
                {
                    string Filename = Application.StartupPath + @"\..\Resource\Images\Icon\fireHydrant.png";
                    double xfea, yfea;
                    xfea = (feature.Extent.XMax + feature.Extent.XMin) / 2;
                    yfea = (feature.Extent.YMax + feature.Extent.YMin) / 2;
                    IPoint pPoint = new PointClass();
                    pPoint.PutCoords(xfea, yfea);
                    IPictureMarkerSymbol pPictureMarkerSymbol = new PictureMarkerSymbolClass();
                    pPictureMarkerSymbol.Size = 50;
                    pPictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG, Filename);
                    IMarkerElement pMarkerElement = new MarkerElementClass();
                    pMarkerElement.Symbol = pPictureMarkerSymbol as IMarkerSymbol;
                    IElement pElement = (IElement)pMarkerElement;
                    pElement.Geometry = pPoint;
                    pGraphicsContainer.AddElement(pElement, 0);
                }
                this.m_ActiveView.Refresh();
                WaitForm.Stop();
            }
            catch (System.Exception ex)
            {
                WaitForm.Stop();
                return;
            }
        }
    private ISymbol CreateStandardLogoSymbol()
    {
      IPictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbolClass();
      pictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, m_logoPath);
      pictureMarkerSymbol.Size = 100;
      IColor whiteTransparencyColor = ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(255, 255, 255)) as IColor;
      pictureMarkerSymbol.BitmapTransparencyColor = whiteTransparencyColor;

      return pictureMarkerSymbol as ISymbol;
    }
Example #28
0
        //TextSymbol
        private void button18_Click(object sender, EventArgs e)
        {
            ITextSymbol textSymbol = new TextSymbolClass();

            System.Drawing.Font drawFont = new System.Drawing.Font("宋体", 16, FontStyle.Bold);
            stdole.IFontDisp    fontDisp = (stdole.IFontDisp)(new stdole.StdFontClass());
            textSymbol.Font  = fontDisp;
            textSymbol.Color = getRGB(0, 255, 0);
            textSymbol.Size  = 20;
            IPolyline polyline = new PolylineClass();
            IPoint    point    = new PointClass();

            point.PutCoords(1, 1);
            polyline.FromPoint = point;
            point.PutCoords(10, 10);
            polyline.ToPoint = point;
            ITextPath textPath = new BezierTextPathClass();
            //创建简单标注
            ILineSymbol lineSymbol = new SimpleLineSymbolClass();

            lineSymbol.Color = getRGB(255, 0, 0);
            lineSymbol.Width = 5;
            ISimpleTextSymbol simpleTextSymbol = textSymbol as ISimpleTextSymbol;

            simpleTextSymbol.TextPath = textPath;
            object      oLineSymbol = lineSymbol;
            object      oTextSymbol = textSymbol;
            IActiveView activeView  = this.axMapControl1.ActiveView;

            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(oLineSymbol as ISymbol);
            activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry);
            activeView.ScreenDisplay.SetSymbol(oTextSymbol as ISymbol);
            activeView.ScreenDisplay.DrawText(polyline as IGeometry, "简单标注");;
            activeView.ScreenDisplay.FinishDrawing();

            //创建气泡标注(两中风格,一种是有锚点,一种是marker方式)
            //锚点方式
            ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();

            simpleFillSymbol.Color = getRGB(0, 255, 0);
            simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid;
            IBalloonCallout balloonCallout = new BalloonCalloutClass();

            balloonCallout.Style           = esriBalloonCalloutStyle.esriBCSRectangle;
            balloonCallout.Symbol          = simpleFillSymbol;
            balloonCallout.LeaderTolerance = 10;

            point.PutCoords(5, 5);
            balloonCallout.AnchorPoint = point;

            IGraphicsContainer   graphicsContainer   = activeView as IGraphicsContainer;
            IFormattedTextSymbol formattedTextSymbol = new TextSymbolClass();

            formattedTextSymbol.Color = getRGB(0, 0, 255);
            point.PutCoords(10, 5);
            ITextBackground textBackground = balloonCallout as ITextBackground;

            formattedTextSymbol.Background = textBackground;
            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(formattedTextSymbol as ISymbol);
            activeView.ScreenDisplay.DrawText(point as IGeometry, "气泡1");
            activeView.ScreenDisplay.FinishDrawing();


            //marker方式
            textSymbol                     = new TextSymbolClass();
            textSymbol.Color               = getRGB(255, 0, 0);
            textSymbol.Angle               = 0;
            textSymbol.RightToLeft         = false;
            textSymbol.VerticalAlignment   = esriTextVerticalAlignment.esriTVABaseline;
            textSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHAFull;


            IMarkerTextBackground markerTextBackground = new MarkerTextBackgroundClass();

            markerTextBackground.ScaleToFit = true;
            markerTextBackground.TextSymbol = textSymbol;

            IRgbColor            rgbColor            = new RgbColorClass();
            IPictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbolClass();
            //string fileName = @"E:\vs2005\第五章\lesson2\lesson2\data\qq.bmp";
            string path     = Directory.GetCurrentDirectory();
            string fileName = path + @"\qq.bmp";

            pictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, fileName);
            pictureMarkerSymbol.Angle = 0;
            pictureMarkerSymbol.BitmapTransparencyColor = rgbColor;
            pictureMarkerSymbol.Size    = 20;
            pictureMarkerSymbol.XOffset = 0;
            pictureMarkerSymbol.YOffset = 0;

            markerTextBackground.Symbol = pictureMarkerSymbol as IMarkerSymbol;

            formattedTextSymbol       = new TextSymbolClass();
            formattedTextSymbol.Color = getRGB(255, 0, 0);
            fontDisp.Size             = 10;
            fontDisp.Bold             = true;
            formattedTextSymbol.Font  = fontDisp;

            point.PutCoords(15, 5);

            formattedTextSymbol.Background = markerTextBackground;
            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(formattedTextSymbol as ISymbol);
            activeView.ScreenDisplay.DrawText(point as IGeometry, "气泡2");
            activeView.ScreenDisplay.FinishDrawing();
        }
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add BufferPointTool.OnMouseDown implementation
            pActiveView = m_hookHelper.ActiveView;
            pMap        = m_hookHelper.FocusMap;
            pMap.ClearSelection();
            IGraphicsContainer pGrap = pActiveView as IGraphicsContainer;

            pGrap.DeleteAllElements();//删除所添加的图片要素

            string layerName = "points";
            ILayer pLayer    = null;

            for (int i = 0; i < pMap.LayerCount; i++)
            {
                pLayer = pMap.get_Layer(i);
                if (pLayer.Name == layerName)
                {
                    mFeatureLayer = (IFeatureLayer)pLayer;
                    break;
                }
            }
            IFeatureClass pFeatureClass = mFeatureLayer.FeatureClass;
            IPoint        pPoint        = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            IPictureMarkerSymbol pPicturemksb = new PictureMarkerSymbolClass();

            pPicturemksb.Size = 30;
            string picturePath = getPath(path1) + "\\Image\\景点.png";

            pPicturemksb.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG, picturePath);
            IMarkerElement pMarkerEle = new MarkerElement() as IMarkerElement;

            pMarkerEle.Symbol = pPicturemksb as IMarkerSymbol;
            IElement pEle = (IElement)pMarkerEle;

            pEle.Geometry = pPoint;
            IGraphicsContainer pGraphicsContainer = pActiveView.GraphicsContainer;

            pGraphicsContainer.AddElement(pEle, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

            ITopologicalOperator pTopo;

            pTopo = pPoint as ITopologicalOperator;
            IGeometry pBuffer;

            pBuffer = pTopo.Buffer(bufferdis);
            IGeometry      pGeometry = pBuffer.Envelope;
            ISpatialFilter pSpatialFilter;

            pSpatialFilter            = new SpatialFilterClass();
            pSpatialFilter.Geometry   = pGeometry;
            pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;
            IFeatureCursor pFeatureCursor = pFeatureClass.Search(pSpatialFilter, false);
            IFeature       pFeature       = pFeatureCursor.NextFeature();

            bool featurenull = false;

            if (pFeature == null)
            {
                featurenull = true;
                String tip = "抱歉,在该点附近" + (bufferdis * 100000).ToString() + "米没有您要找的地点!";
                MessageBox.Show(tip.ToString());
                pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
            }
            int count = 0;

            while (pFeature != null)
            {
                string  fieldName  = "type";
                IFields fields     = mFeatureLayer.FeatureClass.Fields;
                int     fieldIndex = fields.FindField(fieldName);
                if (pFeature.get_Value(fieldIndex).ToString() == type)
                {
                    count++;
                    pMap.SelectFeature(mFeatureLayer, pFeature);
                    IPoint POI = pFeature.Shape as IPoint;
                    AddMarker(POI);
                }
                pFeature = pFeatureCursor.NextFeature();
            }
            if (count == 0 && featurenull == false)
            {
                String tip = "抱歉,在该点附近" + (bufferdis * 100000).ToString() + "米没有您要找的地点!";
                MessageBox.Show(tip.ToString());
                pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
            }

            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
        }
		/// <summary>
    /// Initialize a character marker symbol for a given bitmap path
		/// </summary>
		/// <param name="iconPath"></param>
		/// <param name="iconWidth"></param>
		/// <param name="iconHeight"></param>
		/// <returns></returns>
    private ISymbol InitializeSymbol(string iconPath, out int iconWidth, out int iconHeight, out Bitmap bitmap)
		{
			iconWidth = iconHeight = 0;
			bitmap = null;
			try
			{ 
				//make sure that the icon exit on dist or else download it
				bitmap = DownloadIcon(iconPath, out iconWidth, out iconHeight);
				string iconFileName = System.IO.Path.Combine(m_iconFolder, System.IO.Path.GetFileNameWithoutExtension(iconPath) + ".bmp");
				if(!System.IO.File.Exists(iconFileName))
					return null;
				
        //initialize the transparent color
				IRgbColor rgbColor = new RgbColorClass();
				rgbColor.Red = 255;
				rgbColor.Blue = 255;
				rgbColor.Green = 255;
				
				//instantiate the marker symbol and set its properties
        IPictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbolClass();
				pictureMarkerSymbol.CreateMarkerSymbolFromFile(ESRI.ArcGIS.Display.esriIPictureType.esriIPictureBitmap, iconFileName);
				pictureMarkerSymbol.Angle = 0;
        pictureMarkerSymbol.Size = m_symbolSize;
				pictureMarkerSymbol.XOffset = 0;
				pictureMarkerSymbol.YOffset = 0;
				pictureMarkerSymbol.BitmapTransparencyColor = rgbColor as IColor;

				//return the symbol
        return (ISymbol)pictureMarkerSymbol;
			}
			catch
			{
				return null;
			}
		}
Example #31
0
        private static IPictureMarkerSymbol MakeMarkerSymbol(string filePath, double size)
        {
            if (!System.IO.File.Exists(filePath))
              {
              Console.WriteLine("Source MarkerSymbol does NOT exist: " + filePath);
              return null;
              }

              bool isVector = (filePath.Substring(filePath.Length - 4) == ".emf");
              esriIPictureType picType = (isVector) ? esriIPictureType.esriIPictureEMF : esriIPictureType.esriIPicturePNG;

              IPictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbolClass();
              pictureMarkerSymbol.CreateMarkerSymbolFromFile(picType, filePath);
              pictureMarkerSymbol.Size = size;
              return pictureMarkerSymbol;
        }
Example #32
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            mMapControl.Map.ClearSelection(); //清除上次查询结果

            ILayer pLayer;

            for (int i = 0; i < this.mMapControl.LayerCount; i++)
            {
                pLayer = this.mMapControl.get_Layer(i);
                if (pLayer.Name == "points")
                {
                    mFeatureLayer = pLayer as IFeatureLayer;
                    break;
                }
            }
            IActiveView        pActiveView = mMapControl.Map as IActiveView;
            IGraphicsContainer pGrap       = pActiveView as IGraphicsContainer;

            pGrap.DeleteAllElements();//清除marker图片

            IQueryFilter pQueryFilter = new QueryFilterClass();

            //设置查询过滤条件
            pQueryFilter.WhereClause = "name = '" + listBox1.Text + "'";
            //查询 ,search的参数第一个为过滤条件,第二个为是否重复执行
            IFeatureCursor pFeatureCursor = mFeatureLayer.Search(pQueryFilter, false);
            //获取查询到的要素
            IFeature pFeature = pFeatureCursor.NextFeature();

            while (pFeature != null)
            {
                mMapControl.Map.SelectFeature(mFeatureLayer, pFeature); //选择要素

                //添加marker
                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 = getPath(path1) + "\\Image\\景点.png";
                //添加自定义站点图片
                pms.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG, picturePath);
                pms.Size = 30;
                IMarkerElement pMarkerEle = new MarkerElementClass();
                pMarkerEle.Symbol = pms as IMarkerSymbol;
                IElement pEle = pMarkerEle as IElement;
                pEle.Geometry = pFeature.Shape as IGeometry;
                pGrap.AddElement(pEle, 1);

                //放大到要素
                IPoint mPoint = pFeature.Shape as IPoint;
                double expand = 0.05;
                ITopologicalOperator mTopoOperator  = mPoint as ITopologicalOperator;
                IPolygon             mPolygonBuffer = mTopoOperator.Buffer(expand) as IPolygon;
                mMapControl.Extent = mPolygonBuffer.Envelope;

                pFeature = pFeatureCursor.NextFeature();
            }
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
            pActiveView.Refresh();//刷新图层

            SetPic(listBox1.Text);
        }
Example #33
0
        private static IPictureMarkerSymbol MakeMarkerSymbol(string renderPath, string icon, int size, int display, bool isVector)
        {
            esriIPictureType picType = (isVector) ? esriIPictureType.esriIPictureEMF : esriIPictureType.esriIPicturePNG;
              string extrafileName = (display == 2) ? "@2x" : "";
              string suffix = (picType == esriIPictureType.esriIPictureEMF) ? ".emf" : ".png";

              IPictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbolClass();
              pictureMarkerSymbol.CreateMarkerSymbolFromFile(picType, renderPath + "\\" + icon + "-" + size + extrafileName + suffix);
              pictureMarkerSymbol.Size = (((Double)size / 96.0) * 72.0); //so it is 1to1 at 96 dpi or twize that for retina
              return pictureMarkerSymbol;
        }