예제 #1
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (m_hookHelper.Hook == null)
            {
                return;
            }
            IMapControl2 pMapCtl = m_hookHelper.Hook as IMapControl2;

            ESRI.ArcGIS.Geometry.IGeometry pGeometry = pMapCtl.TrackPolygon();
            if (pGeometry == null)
            {
                return;
            }
            ESRI.ArcGIS.Carto.IMap pMap = m_hookHelper.FocusMap;
            IArea  pArea = pGeometry as IArea;
            double area  = pArea.Area;

            GetArea(ref area, pMap);
            double dArea = SysCommon.ModSysSetting.GetExportAreaOfUser(Plugin.ModuleCommon.TmpWorkSpace, m_pAppForm.ConnUser);

            if (dArea >= 0 && area > dArea)
            {
                MessageBox.Show("超过提取最大面积", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            drawgeometryXOR(pGeometry);
            frm          = new frmExport(pMap, pGeometry);
            frm.WriteLog = WriteLog;//ygc 2012-9-12 是否写日志
            frm.m_area   = area;
            //ZQ 2011 1126 modify
            SysCommon.ScreenDraw.list.Add(ToolPolygonExportAfterDraw);
            frm.FormClosed += new FormClosedEventHandler(frm_FormClosed);
            frm.ShowDialog();
        }
예제 #2
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (m_hookHelper.Hook == null)
            {
                return;
            }
            IMapControl2 pMapCtl = m_hookHelper.Hook as IMapControl2;

            ESRI.ArcGIS.Geometry.IGeometry pGeometry = pMapCtl.TrackPolygon();
            if (pGeometry == null)
            {
                return;
            }
            if (pGeometry.GeometryType != esriGeometryType.esriGeometryPolygon)
            {
                return;
            }

            ESRI.ArcGIS.Carto.IMap pMap = m_hookHelper.FocusMap;
            IGraphicsContainer     pGra = pMap as IGraphicsContainer;

            GeoPageLayout gpl = new GeoPageLayout(pMap, pGeometry);

            gpl.typePageLayout = 2;
            gpl.MapOut();
            gpl = null;
        }
예제 #3
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            if (m_hookHelper.Hook == null)
            {
                return;
            }

            List <IGeometry> vTemp = GetDataGeometry(m_hookHelper.FocusMap);

            if (vTemp == null)
            {
                return;
            }
            ESRI.ArcGIS.Geometry.IGeometry pGeometry = GetUnion(vTemp);

            if (pGeometry == null)
            {
                return;
            }

            ESRI.ArcGIS.Carto.IMap pMap = m_hookHelper.FocusMap;
            GeoPageLayout          gpl  = new GeoPageLayout(pMap, pGeometry);

            gpl.typePageLayout = 2;
            gpl.MapOut();
            gpl = null;
        }
예제 #4
0
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            {
                object missing = Type.Missing;
                if (bCreateOrNot)
                {
                    axMapControl1.CurrentTool = null;

                    ESRI.ArcGIS.Geometry.IGeometry pGeometry = axMapControl1.TrackPolygon();

                    pGeometryCollection.AddGeometry(pGeometry, ref missing, ref missing);
                    ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbol();
                    pSimpleLineSymbol.Color = GetAEColor(this.listView1.Items.Count + 1);
                    pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
                    ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbol();
                    pSimpleFillSymbol.Color = GetAEColor(this.listView1.Items.Count + 1);
                    IFillShapeElement pFillElement = new PolygonElementClass();
                    pFillElement.Symbol = pSimpleFillSymbol;
                    IElement pElement;

                    pElement          = pFillElement as IElement;
                    pElement.Geometry = pGeometry;
                    pGraphic          = axMapControl1.ActiveView as IGraphicsContainer;
                    pGraphic.AddElement(pElement, 0);
                    axMapControl1.Refresh();

                    polyGonCount            += 1;
                    this.txtSampleCount.Text = polyGonCount.ToString();

                    IElementProperties pElementProperties = pElement as IElementProperties;
                    pElementProperties.Name = txtClassID.Text;
                }
            }
        }
예제 #5
0
        public IGeometry DrawPolyline(ESRI.ArcGIS.Carto.IActiveView activeView)
        {
            if (activeView == null)
            {
                return(null);
            }
            ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay;

            // Constant
            screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast
            ESRI.ArcGIS.Display.IRgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColor();
            rgbColor.Red = 255;

            ESRI.ArcGIS.Display.IColor            color            = rgbColor; // Implicit Cast
            ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbol();
            simpleLineSymbol.Color = color;
            simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDot;

            ESRI.ArcGIS.Display.ISymbol     symbol     = (ESRI.ArcGIS.Display.ISymbol)simpleLineSymbol; // Explicit Cast
            ESRI.ArcGIS.Display.IRubberBand rubberBand = new RubberLine();
            ESRI.ArcGIS.Geometry.IGeometry  geometry   = rubberBand.TrackNew(screenDisplay, symbol);
            screenDisplay.SetSymbol(symbol);
            screenDisplay.DrawPolyline(geometry);
            screenDisplay.FinishDrawing();
            return(geometry);
        }
예제 #6
0
        /// <summary>
        /// Occurs when this tool is clicked
        /// </summary>
        public override void OnClick()
        {
            if (m_hookHelper.FocusMap == null)
            {
                return;
            }

            List <IGeometry> vTemp = GetDataGeometry(m_hookHelper.FocusMap);

            if (vTemp == null)
            {
                return;
            }
            ESRI.ArcGIS.Geometry.IGeometry pGeometry = GetUnion(vTemp);

            if (pGeometry == null)
            {
                return;
            }
            //DrawGeometry(pGeometry);
            frmAreaStatistics frm = new frmAreaStatistics();

            frm.CurGeometry = pGeometry;
            frm.CurMap      = m_hookHelper.Hook as IMapControlDefault;
            // frm.SetSliderValue(false);
            frm.InitFrm();
            frm.ShowDialog();
        }
예제 #7
0
        void ESRI.ArcGIS.Display.ISymbol.Draw(ESRI.ArcGIS.Geometry.IGeometry Geometry)
        {
            if (m_lhDC == 0 | m_colorTop == null | m_colorLeft == null | m_colorRight == null | m_colorBorder == null)
                return;
            if (Geometry == null)
                return;
            if (!(Geometry is ESRI.ArcGIS.Geometry.IPoint))
                return;

            // Transform the Point coords to device coords, accounting for rotation, offset etc.
            ESRI.ArcGIS.Geometry.IPoint point = (IPoint)Geometry;

            int lCenterX = 0;
            int lCenterY = 0;

            Utility.FromMapPoint(m_trans, ref point, ref lCenterX, ref lCenterY);
            double tempy1 = System.Convert.ToDouble(lCenterY);
            CalcCoords(System.Convert.ToDouble(lCenterX), ref tempy1);

            //  Draw the chord, and two polygons, and flood fill them.
            //int lResult = 0;
            //int lTempBrush = 0;
            //m_lOldBrush = Utility.SelectObject(m_lhDC, m_lBrushTop);
            //lResult = Utility.Chord(m_lhDC, m_coords[5].x, m_coords[5].y, m_coords[6].x, m_coords[6].y, m_coords[4].x, m_coords[4].y, m_coords[1].x, m_coords[1].y);

            //Utility.SelectObject(m_lhDC, m_lBrushLeft);
            //lResult = Utility.Polygon(m_lhDC, ref m_coords[1], 3);

            //Utility.SelectObject(m_lhDC, m_lBrushRight);
            //lResult = Utility.Polygon(m_lhDC, ref m_coords[2], 3);

            //Utility.SelectObject(m_lhDC, m_lOldBrush);
        }
예제 #8
0
        public void add(int ClassID, string ClassName, ESRI.ArcGIS.Geometry.IGeometry Geo, int OID, int EID, IFeature pFeat)
        {
            FeatureDetails pFD = new FeatureDetails();

            FieldPairs[] fps    = new FieldPairs[pFeat.Fields.FieldCount - 1];
            int          fldIdx = 0;

            for (int i = 0; i < pFeat.Fields.FieldCount; i++)
            {
                if (pFeat.Fields.get_Field(i).Type == esriFieldType.esriFieldTypeGeometry)
                {
                }
                else
                {
                    FieldPairs fp = new FieldPairs();
                    fp.FieldAlias = pFeat.Fields.get_Field(i).AliasName;
                    fp.FieldName  = pFeat.Fields.get_Field(i).Name;
                    if (pFeat.get_Value(i) == null)
                    {
                        fp.FieldValue = "";
                    }
                    else
                    {
                        fp.FieldValue = pFeat.get_Value(i).ToString();
                    }
                    fps[fldIdx] = fp;

                    fldIdx++;
                }
            }
            pFD.Fields = fps;

            pFD.Geo = Geo;
            pFD.OID = OID;
            pFD.EID = EID;
            TraceResultsClass trRes = TraceResultClassItem(ClassID);

            if (trRes == null)
            {
                trRes           = new TraceResultsClass();
                trRes.ClassID   = ClassID;
                trRes.ClassName = ClassName;
                if (trRes.Features == null)
                {
                    trRes.Features = new ArrayList();
                }

                trRes.Features.Add(pFD);
                m_TraceResultItems.Add(trRes);
            }
            else
            {
                if (trRes.Features == null)
                {
                    trRes.Features = new ArrayList();
                }
                trRes.Features.Add(pFD);
            }
        }
예제 #9
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (m_hookHelper.Hook == null)
            {
                return;
            }
            IMapControl2 pMapCtl = m_hookHelper.Hook as IMapControl2;

            ESRI.ArcGIS.Geometry.IGeometry pGeometry = pMapCtl.TrackRectangle();
            if (pGeometry == null)
            {
                return;
            }
            if (pGeometry.GeometryType != esriGeometryType.esriGeometryEnvelope)
            {
                return;
            }
            if (pGeometry.Envelope.Width < 0)
            {
                return;
            }
            //pLCCtl.Page.FormID = esriPageFormID.esriPageFormA4;
            //IMapFrame pMapFrame = (IMapFrame)pLCCtl.GraphicsContainer.FindFrame(pLCCtl.ActiveView.FocusMap);

            //IElement pMapEle = pMapFrame as IElement;
            //pMapEle.Geometry = pExtent as IGeometry;


            //pLCCtl.ZoomToWholePage();
            //FrmScale pfrmScale = new FrmScale();
            //if (pfrmScale.ShowDialog() != DialogResult.OK)
            //    return;

            //createPageLayout_Rectangle(pfrmScale.ScaleSet);
            if (this.WriteLog)
            {
                Plugin.LogTable.Writelog("矩形范围制图");//xisheng 日志记录07.08
            }
            drawgeometryXOR(pGeometry as IEnvelope, m_pScreenDisplay);
            ESRI.ArcGIS.Carto.IMap pMap = m_hookHelper.FocusMap;
            SysCommon.CProgress    pgss = new SysCommon.CProgress("正在加载制图界面,请稍候...");
            pgss.EnableCancel    = false;
            pgss.ShowDescription = false;
            pgss.FakeProgress    = true;
            pgss.TopMost         = true;
            pgss.ShowProgress();
            Application.DoEvents();
            frm             = new FrmPageLayout(m_hookHelper.FocusMap, pGeometry);
            frm.WriteLog    = WriteLog;//ygc 2012-9-12 是否写日志
            frm.FormClosed += new FormClosedEventHandler(frm_FormClosed);
            frm.typeZHT     = 2;
            frm.Show();
            pgss.Close();
            pMapCtl.CurrentTool = null;
            Application.DoEvents();
        }
예제 #10
0
        /// <summary>
        /// Adds a graphic element to the map graphics container
        /// Returns GUID
        /// </summary>
        /// <param name="geom">IGeometry</param>
        ///


        public static void FlashGeometry(
            ESRI.ArcGIS.Geometry.IGeometry geometry,
            System.Int32 delay)
        {
            if (!EsriTools.IsPointOnExtent(ArcMap.Document.ActivatedView.Extent, geometry as IPoint))
            {
                EsriTools.PanToGeometry(ArcMap.Document.ActiveView, geometry, true);
            }
            EsriTools.FlashGeometry(geometry, delay, ArcMap.Application);
        }
예제 #11
0
파일: ArcMapHelper.cs 프로젝트: VsPun/DPP
        public static void FlashGeometry(ESRI.ArcGIS.Geometry.IGeometry geometry,
                                         System.Int32 delay)
        {
            var mxdoc = ArcMap.Application.Document as IMxDocument;

            if (mxdoc == null)
            {
                return;
            }

            var av       = (IActiveView)mxdoc.FocusMap;
            var display  = av.ScreenDisplay;
            var envelope = av.Extent.Envelope;

            IRgbColor color = new RgbColorClass();

            color.Green = 255;
            color.Red   = 0;
            color.Blue  = 0;

            if ((geometry == null) || (color == null) || (display == null) || (envelope == null) || (delay < 0))
            {
                return;
            }

            display.StartDrawing(display.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast

            if (geometry.GeometryType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint)
            {
                return;
            }

            //Set the flash geometry's symbol.
            ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbolClass();
            simpleMarkerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle;
            simpleMarkerSymbol.Size  = 12;
            simpleMarkerSymbol.Color = color;
            ESRI.ArcGIS.Display.ISymbol markerSymbol = (ESRI.ArcGIS.Display.ISymbol)simpleMarkerSymbol;
            markerSymbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;

            ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
            simpleLineSymbol.Width = 1;
            simpleLineSymbol.Color = color;
            ESRI.ArcGIS.Display.ISymbol lineSymbol = (ESRI.ArcGIS.Display.ISymbol)simpleLineSymbol;
            lineSymbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;

            DrawCrossHair(geometry, display, envelope, markerSymbol, lineSymbol);

            //Flash the input point geometry.
            display.SetSymbol(markerSymbol);
            display.DrawPoint(geometry);
            System.Threading.Thread.Sleep(delay);
            display.DrawPoint(geometry);
            display.FinishDrawing();
        }
예제 #12
0
        public ESRI.ArcGIS.Geometry.IPoint GetPointFromMouseClicks(ESRI.ArcGIS.Carto.IActiveView activeView)
        {
            ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay;

            ESRI.ArcGIS.Display.IRubberBand rubberBand = new ESRI.ArcGIS.Display.RubberPoint();
            ESRI.ArcGIS.Geometry.IGeometry  geometry   = rubberBand.TrackNew(screenDisplay, null);

            ESRI.ArcGIS.Geometry.IPoint point = (ESRI.ArcGIS.Geometry.IPoint)geometry;

            return(point);
        }
예제 #13
0
        public void FlashGeometryAndZoom(ESRI.ArcGIS.Geometry.IGeometry geometry)
        {
            IEnvelope env = geometry.Envelope;

            env.Expand(2, 2, true);

            ArcMap.Document.ActiveView.Extent = env;

            ArcMap.Document.ActiveView.Refresh();

            FlashGeometry(geometry);
        }
예제 #14
0
        /// <summary>
        /// Converts point geometry to geohash
        /// </summary>
        /// <param name="geometry">The input geometry</param>
        /// <param name="precision">The precision.</param>
        /// <returns>geohash string</returns>
        public static string ToGeohash(this ESRI.ArcGIS.Geometry.IGeometry geometry, int precision)
        {
            string geohash = string.Empty;

            if (geometry is IPoint)
            {
                IPoint point = (IPoint)geometry as IPoint;
                geohash = Umbriel.ArcMap.Editor.Util.Geohasher.CreateGeohash(point, 13);
            }

            return(geohash);
        }
예제 #15
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            if (m_hookHelper.Hook == null)
            {
                return;
            }
            //IFeatureLayer tmpFeatureLayer = layerCurSeleted();
            //if (tmpFeatureLayer == null)
            //{
            //    MessageBox.Show("请在地图目录设置当前选择图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //    return;
            //}
            try
            {
                //if (m_hookHelper.FocusMap.SelectionCount > 100)
                //int ooo = m_hookHelper.FocusMap.SelectionCount;
                List <IGeometry> vTemp = GetDataGeometry(m_hookHelper.FocusMap);
                if (vTemp == null)
                {
                    return;
                }
                SysCommon.CProgress pgss = new SysCommon.CProgress("正在加载制图界面,请稍候...");
                pgss.EnableCancel    = false;
                pgss.ShowDescription = false;
                pgss.FakeProgress    = true;
                pgss.TopMost         = true;
                pgss.ShowProgress();

                //ITopologicalOperator pTO = GetUnion(vTemp) as ITopologicalOperator;

                ESRI.ArcGIS.Geometry.IGeometry pGeometry = GetUnion(vTemp);

                m_hookHelper.FocusMap.ClearSelection();

                //m_hookHelper.ActiveView.Extent=pGeometry.Envelope;
                m_hookHelper.ActiveView.Refresh();
                Application.DoEvents();
                drawgeometryXOR(pGeometry as IPolygon, m_pScreenDisplay);

                frm             = new FrmPageLayout(m_hookHelper.FocusMap, pGeometry);
                frm.WriteLog    = WriteLog;//ygc 2012-9-12 是否写日志
                frm.FormClosed += new FormClosedEventHandler(frm_FormClosed);
                frm.typeZHT     = 2;
                frm.Show();
                pgss.Close();
                Application.DoEvents();
            }
            catch (Exception exError)
            {
                ErrorHandle.ShowFrmErrorHandle("提示", exError.Message);
            }
        }
예제 #16
0
        private void dblBuffLen_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                //控制只输入数字
                string strTemp = "";
                strTemp = this.dblBuffLen.Text.Trim();
                if (strTemp == "")
                {
                    this.dblBuffLen.Text = "0";
                }
                else
                {
                    if (strTemp.Length != 1 && strTemp.Substring(strTemp.Length - 1) == ".")
                    {
                        return;
                    }
                }


                double dblTemp = 0;
                if (!double.TryParse(this.dblBuffLen.Text, out dblTemp))
                {
                    this.dblBuffLen.Text = dblbufSize.ToString();
                    return;
                }
                dblbufSize = dblTemp;


                //联动
                this.sliderBuffer.Value = Convert.ToInt32(dblBuffLen.Text);
                //获得缓冲范围
                m_pGeometry = GetBufferGeometry(m_pGeometry, GetBuffSize());

                //画element
                //先删除
                if (m_pMap == null)
                {
                    return;
                }
                IGraphicsContainer pMapGraphics = (IGraphicsContainer)m_pMap.Map;
                if (m_pElement != null)
                {
                    pMapGraphics.DeleteElement(m_pElement);
                }

                m_pElement = SysCommon.Gis.ModGisPub.DoDrawGeometry(m_pMap, m_pGeometry, 128, 128, 128, false);
                m_pMap.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            }
        }
예제 #17
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button != 1)
            {
                return;
            }
            IFeatureLayer curLayer = getEditLayer.isExistLayer(m_MapControl.Map) as IFeatureLayer;

            if (curLayer == null)
            {
                return;
            }
            IFeatureSelection curLayerSn = curLayer as IFeatureSelection;

            IMapControl2 pMapCtl = m_hookHelper.Hook as IMapControl2;

            ESRI.ArcGIS.Geometry.IGeometry pGeometry = pMapCtl.TrackPolygon();
            if (pGeometry == null)
            {
                return;
            }
            if (pGeometry.GeometryType != esriGeometryType.esriGeometryPolygon)
            {
                return;
            }



            IFeature pFeatureCreated = IFeatureClass_Create(curLayer.FeatureClass, pGeometry);

            m_MapControl.ActiveView.Refresh();
            if (pFeatureCreated == null)
            {
                return;
            }

            //curLayerSn.Clear();
            pMapCtl.Map.FeatureSelection.Clear();
            curLayerSn.Add(pFeatureCreated);//选择刚创建的point
            m_MapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
            //m_MapControl.Map.FeatureSelection.Clear();
            //m_MapControl.Map.FeatureSelection =curLayerSn as ISelection;

            //g = 3 + 7;
            //m_MapControl.ActiveView.Refresh();
        }
예제 #18
0
        public void AddGraphicToMap(ESRI.ArcGIS.Carto.IMap map, ESRI.ArcGIS.Geometry.IGeometry geometry, ESRI.ArcGIS.Display.IRgbColor rgbColor, ESRI.ArcGIS.Display.IRgbColor outlineRgbColor)
        {
            ESRI.ArcGIS.Carto.IGraphicsContainer graphicsContainer = (ESRI.ArcGIS.Carto.IGraphicsContainer)map; // Explicit Cast
            ESRI.ArcGIS.Carto.IElement           element           = null;
            if ((geometry.GeometryType) == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint)
            {
                // Marker symbols
                ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbol();
                simpleMarkerSymbol.Color        = rgbColor;
                simpleMarkerSymbol.Outline      = true;
                simpleMarkerSymbol.OutlineColor = outlineRgbColor;
                simpleMarkerSymbol.Size         = frmOptions.sizeOfPoints;
                simpleMarkerSymbol.Style        = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle;

                ESRI.ArcGIS.Carto.IMarkerElement markerElement = (IMarkerElement) new ESRI.ArcGIS.Carto.MarkerElement();
                markerElement.Symbol = simpleMarkerSymbol;
                element = (ESRI.ArcGIS.Carto.IElement)markerElement; // Explicit Cast
            }
            else if ((geometry.GeometryType) == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline)
            {
                //  Line elements
                ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbol();
                simpleLineSymbol.Color = rgbColor;
                simpleLineSymbol.Style = ESRI.ArcGIS.Display.esriSimpleLineStyle.esriSLSSolid;
                simpleLineSymbol.Width = frmOptions.sizeOfLines;

                ESRI.ArcGIS.Carto.ILineElement lineElement = (ILineElement) new ESRI.ArcGIS.Carto.LineElement();
                lineElement.Symbol = simpleLineSymbol;
                element            = (ESRI.ArcGIS.Carto.IElement)lineElement; // Explicit Cast
            }
            else if ((geometry.GeometryType) == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon)
            {
                // Polygon elements
                ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbol();
                simpleFillSymbol.Color = rgbColor;
                simpleFillSymbol.Style = ESRI.ArcGIS.Display.esriSimpleFillStyle.esriSFSForwardDiagonal;
                ESRI.ArcGIS.Carto.IFillShapeElement fillShapeElement = (IFillShapeElement) new ESRI.ArcGIS.Carto.PolygonElement();
                fillShapeElement.Symbol = simpleFillSymbol;
                element = (ESRI.ArcGIS.Carto.IElement)fillShapeElement; // Explicit Cast
            }
            if (!(element == null))
            {
                element.Geometry = geometry;
                graphicsContainer.AddElement(element, 0);
            }
        }
예제 #19
0
        /// <summary>
        /// 在地图上绘制指定颜色的文字
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="geometry"></param>
        /// <param name="OffsetZs"></param>
        /// <param name="rgbColor"></param>
        /// <param name="text"></param>
        /// <param name="fontSize"></param>
        /// <returns></returns>
        internal static IElement AddTextGraphicToScene(IScene scene, ESRI.ArcGIS.Geometry.IGeometry geometry, double OffsetZs, ESRI.ArcGIS.Display.IRgbColor rgbColor, string text, int fontSize)
        {
            IGraphicsContainer3D graphicsContainer3D = (IGraphicsContainer3D)scene.BasicGraphicsLayer;

            IText3DElement    pTextElement      = new Text3DElementClass();
            IFillShapeElement pFillShapeElement = new Text3DElementClass();

            pTextElement.Text = text;


            IFillSymbol pFillSymbol = new SimpleFillSymbol();

            pFillSymbol.Color = rgbColor;//填充的颜色

            IPoint point;

            try
            {
                IArea3D Area3D = (IArea3D)geometry;

                point = Area3D.Centroid3D;
            }
            catch
            {
                point = (IPoint)geometry;
                GeometryUtilities.MakeZAware(point);
            }
            point.Z = point.Z + OffsetZs;
            pTextElement.AnchorPoint      = point;                                     //添加文本的坐标点
            pTextElement.Justification    = esriT3DJustification.esriT3DJustifyCenter; //注记排放方式
            pTextElement.OrientationPlane = esriT3DOrientationPlane.esriT3DPlaneXY;    //注记的旋转平面
            pTextElement.AxisRotation     = esriT3DRotationAxis.esriT3DRotateAxisZ;    //注记旋转轴
            //pTextElement.RotationAngle=....;//注记的旋转角度

            pTextElement.ZAxisScale = 1;
            pTextElement.Depth      = 0.6;      //文本的深度
            pTextElement.Height     = fontSize; //文本的高度,即文字大小
            pTextElement.Update();
            pFillShapeElement        = (IFillShapeElement)pTextElement;
            pFillShapeElement.Symbol = pFillSymbol;

            graphicsContainer3D.AddElement(pTextElement as IElement);
            return(pTextElement as IElement);
        }
 public void DrawRectangle(ESRI.ArcGIS.Carto.IActiveView activeView)
 {
     if (activeView == null)
     {
         return;
     }
     ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay;
     screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast
     ESRI.ArcGIS.Display.IRgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColorClass();
     rgbColor.Red = 255;
     ESRI.ArcGIS.Display.IColor            color            = rgbColor; // Implicit Cast
     ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
     simpleFillSymbol.Color = color;
     ESRI.ArcGIS.Display.ISymbol     symbol     = simpleFillSymbol as ESRI.ArcGIS.Display.ISymbol; // Dynamic Cast
     ESRI.ArcGIS.Display.IRubberBand rubberBand = new ESRI.ArcGIS.Display.RubberEnvelopeClass();
     ESRI.ArcGIS.Geometry.IGeometry  geometry   = rubberBand.TrackNew(screenDisplay, symbol);
     screenDisplay.SetSymbol(symbol);
     screenDisplay.DrawRectangle(geometry as ESRI.ArcGIS.Geometry.IEnvelope); // Dynamic Cast
     screenDisplay.FinishDrawing();
 }
예제 #21
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button != 1)
            {
                return;
            }
            IMapControl2 pMapCtl = m_hookHelper.Hook as IMapControl2;

            ESRI.ArcGIS.Geometry.IGeometry pGeometry = null;
            pGeometry = pMapCtl.TrackLine();//控件画线
            if (pGeometry == null)
            {
                return;
            }
            //简化拓扑
            ITopologicalOperator2 topoOperator = pGeometry as ITopologicalOperator2;

            topoOperator.IsKnownSimple_2 = false;
            topoOperator.Simplify();
            splitFeature(pGeometry);
        }
예제 #22
0
        /// <summary>
        /// 绘制几何图形
        /// </summary>
        /// <param name="geoType"></param>
        /// <param name="geometry"></param>
        /// <returns></returns>
        ESRI.ArcGIS.Carto.IElement createElement_x(ESRI.ArcGIS.Geometry.IGeometry geometry)
        {
            IElement element = null;

            try
            {
                switch (geometry.GeometryType)
                {
                case esriGeometryType.esriGeometryPolyline:    //Polyline线
                    ISimpleLineSymbol simpleLineSymbol = m_NewLineFeedback.Symbol as ISimpleLineSymbol;

                    ILineElement lineElement = new LineElementClass();
                    lineElement.Symbol = simpleLineSymbol as ILineSymbol;
                    element            = lineElement as IElement;
                    element.Geometry   = geometry;
                    break;

                case esriGeometryType.esriGeometryPoint:
                    //设置结点符号
                    IRgbColor pRGB = new RgbColorClass();
                    pRGB.Red   = 255;
                    pRGB.Green = 0;
                    pRGB.Blue  = 0;

                    ISimpleMarkerSymbol pSimpleMarkSymbol = new SimpleMarkerSymbolClass();
                    pSimpleMarkSymbol.Color = pRGB as IColor;
                    pSimpleMarkSymbol.Size  = 2;
                    pSimpleMarkSymbol.Style = esriSimpleMarkerStyle.esriSMSSquare;

                    IMarkerElement pMarkerElement = new MarkerElementClass();
                    pMarkerElement.Symbol = pSimpleMarkSymbol as IMarkerSymbol;
                    element          = pMarkerElement as IElement;
                    element.Geometry = geometry as IGeometry;
                    break;
                }
            }
            catch
            { }
            return(element);
        }
예제 #23
0
        private void CreateFlybyFromPathAnimation(ESRI.ArcGIS.GlobeCore.IGlobe globe, ESRI.ArcGIS.Geodatabase.IFeature lineFeature, ESRI.ArcGIS.Animation.IAGImportPathOptions AGImportPathOptionsCls)
        {
            ESRI.ArcGIS.GlobeCore.IGlobeDisplay globeDisplay = globe.GlobeDisplay;
            ESRI.ArcGIS.Analyst3D.IScene        scene        = globeDisplay.Scene;

            // Get a handle to the animation extension
            ESRI.ArcGIS.Analyst3D.IBasicScene2        basicScene2        = (ESRI.ArcGIS.Analyst3D.IBasicScene2)scene; // Explicit Cast
            ESRI.ArcGIS.Animation.IAnimationExtension animationExtension = basicScene2.AnimationExtension;

            // Get the geometry of the line feature
            ESRI.ArcGIS.Geometry.IGeometry geometry = lineFeature.Shape;

            // Create AGAnimationUtils and AGImportPathOptions objects
            ESRI.ArcGIS.Animation.IAGAnimationUtils AGAnimationUtilsCls = new ESRI.ArcGIS.Animation.AGAnimationUtilsClass();
            AGImportPathOptionsCls.PathGeometry = geometry;

            AGImportPathOptionsCls.AnimationEnvironment = animationExtension.AnimationEnvironment;
            ESRI.ArcGIS.Animation.IAGAnimationContainer AGAnimationContainer = animationExtension.AnimationTracks.AnimationObjectContainer;

            // Call "CreateFlybyFromPath" method
            AGAnimationUtilsCls.CreateFlybyFromPath(AGAnimationContainer, AGImportPathOptionsCls);
        }
예제 #24
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (m_hookHelper.Hook == null)
            {
                return;
            }
            pMapCtl = m_hookHelper.Hook as IMapControl2;

            ESRI.ArcGIS.Geometry.IGeometry pGeometry = pMapCtl.TrackPolygon();
            if (pGeometry == null)
            {
                return;
            }
            if (pGeometry.GeometryType != esriGeometryType.esriGeometryPolygon)
            {
                return;
            }
            if (this.WriteLog)
            {
                Plugin.LogTable.Writelog("多边形范围制图");//xisheng 日志记录07.08
            }
            drawgeometryXOR(pGeometry as IPolygon, m_pScreenDisplay);
            ESRI.ArcGIS.Carto.IMap pMap = m_hookHelper.FocusMap;
            SysCommon.CProgress    pgss = new SysCommon.CProgress("正在加载制图界面,请稍候...");
            pgss.EnableCancel    = false;
            pgss.ShowDescription = false;
            pgss.FakeProgress    = true;
            pgss.TopMost         = true;
            pgss.ShowProgress();
            Application.DoEvents();
            frm             = new FrmPageLayout(m_hookHelper.FocusMap, pGeometry);
            frm.WriteLog    = WriteLog;//ygc 2012-9-12 是否写日志
            frm.FormClosed += new FormClosedEventHandler(frm_FormClosed);
            frm.typeZHT     = 2;
            frm.Show();
            pgss.Close();
            pMapCtl.CurrentTool = null;
            Application.DoEvents();
        }
예제 #25
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (m_hookHelper.Hook == null)
            {
                return;
            }
            IMapControl2 pMapCtl = m_hookHelper.Hook as IMapControl2;

            ESRI.ArcGIS.Geometry.IGeometry pGeometry = null;
            if (strType.Trim() == "Polygon")
            {
                pGeometry = pMapCtl.TrackPolygon();
            }
            else
            {
                pGeometry = pMapCtl.TrackLine();
            }
            if (pGeometry == null)
            {
                return;
            }
            ListGeometrys.Add(pGeometry);
            drawgeometryXOR(pGeometry);
        }
예제 #26
0
        public void FlashGeometry(ESRI.ArcGIS.Geometry.IGeometry geometry)
        {
            try
            {
                IRgbColor color = Globals.FlashFeatureColor;

                IDisplay display = (IDisplay)mDoc.ActiveView.ScreenDisplay;

                Int32 delay = Globals.FlashFeatureDelay;

                if (geometry == null || color == null || display == null)
                {
                    return;
                }
                display.StartDrawing(display.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast

                switch (geometry.GeometryType)
                {
                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
                {
                    //Set the flash geometry's symbol.
                    ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
                    simpleFillSymbol.Color = color;
                    ESRI.ArcGIS.Display.ISymbol symbol = simpleFillSymbol as ESRI.ArcGIS.Display.ISymbol;         // Dynamic Cast
                    symbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;
                    //Flash the input polygon geometry.
                    display.SetSymbol(symbol);
                    display.DrawPolygon(geometry);
                    System.Threading.Thread.Sleep(delay);
                    display.DrawPolygon(geometry);
                    break;
                }

                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
                {
                    //Set the flash geometry's symbol.
                    ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
                    simpleLineSymbol.Width = 4;
                    simpleLineSymbol.Color = color;
                    ESRI.ArcGIS.Display.ISymbol symbol = simpleLineSymbol as ESRI.ArcGIS.Display.ISymbol;         // Dynamic Cast
                    symbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;
                    //Flash the input polyline geometry.
                    display.SetSymbol(symbol);
                    display.DrawPolyline(geometry);
                    System.Threading.Thread.Sleep(delay);
                    display.DrawPolyline(geometry);
                    break;
                }

                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
                {
                    //Set the flash geometry's symbol.
                    ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbolClass();
                    simpleMarkerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle;
                    simpleMarkerSymbol.Size  = 12;
                    simpleMarkerSymbol.Color = color;
                    ESRI.ArcGIS.Display.ISymbol symbol = simpleMarkerSymbol as ESRI.ArcGIS.Display.ISymbol;         // Dynamic Cast
                    symbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;
                    //Flash the input point geometry.
                    display.SetSymbol(symbol);
                    display.DrawPoint(geometry);
                    System.Threading.Thread.Sleep(delay);
                    display.DrawPoint(geometry);
                    break;
                }

                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryMultipoint:
                {
                    //Set the flash geometry's symbol.
                    ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbolClass();
                    simpleMarkerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle;
                    simpleMarkerSymbol.Size  = 12;
                    simpleMarkerSymbol.Color = color;
                    ESRI.ArcGIS.Display.ISymbol symbol = simpleMarkerSymbol as ESRI.ArcGIS.Display.ISymbol;         // Dynamic Cast
                    symbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;
                    //Flash the input multipoint geometry.
                    display.SetSymbol(symbol);
                    display.DrawMultipoint(geometry);
                    System.Threading.Thread.Sleep(delay);
                    display.DrawMultipoint(geometry);
                    break;
                }
                }
                display.FinishDrawing();
            }
            catch (Exception ex) { log.WriteError(ex, TAG, System.Security.Principal.WindowsIdentity.GetCurrent().Name, null); }
        }
        public bool Snap(ESRI.ArcGIS.Geometry.IGeometry geom,
                         ESRI.ArcGIS.Geometry.IPoint point, double tolerance)
        {
            GetFeatureClass();

            bool b_setNewFeatureCache = false;

            if (m_featureClass == null || m_engineeditor == null)
            {
                return(false);
            }

            if (m_featureClass.ShapeType != esriGeometryType.esriGeometryPoint)
            {
                return(false);
            }

            //Check if a feature cache has been created.
            if (!b_setNewFeatureCache)
            {
                m_featureCache       = new FeatureCache();
                b_setNewFeatureCache = true;
            }

            //Fill the cache with the geometries.
            //It is up to the developer to choose an appropriate value
            //given the map units and the scale at which editing will be undertaken.
            FillCache(m_featureClass, point, 10000);

            IProximityOperator proximityOp = point as IProximityOperator;
            double             minDist     = tolerance;

            IPoint               cachePt = new PointClass();
            IPoint               snapPt  = new PointClass();
            IPolygon             outPoly = new PolygonClass();
            ITopologicalOperator topoOp;

            IFeature feature;
            int      Index = 0;

            for (int Count = 0; Count < m_featureCache.Count; Count++)
            {
                feature = m_featureCache.get_Feature(Count);
                cachePt = feature.Shape as IPoint;
                topoOp  = cachePt as ITopologicalOperator;

                //Set the buffer distance to an appropriate value
                //given the map units and data being edited
                outPoly = topoOp.Buffer(1000) as IPolygon;

                double Dist = proximityOp.ReturnDistance(outPoly);
                if (Dist < minDist)
                {
                    Index   = Count;
                    minDist = Dist;
                }
            }

            //Make sure minDist is within the search tolerance.
            if (minDist >= tolerance)
            {
                return(false);
            }

            //Retrieve the feature and its part again.
            feature = m_featureCache.get_Feature(Index);
            cachePt = feature.Shape as IPoint;
            topoOp  = cachePt as ITopologicalOperator;

            //Set the buffer distance to an appropriate value
            //given the map scale and data being edited
            outPoly     = topoOp.Buffer(1000) as IPolygon;
            proximityOp = outPoly as IProximityOperator;
            snapPt      = proximityOp.ReturnNearestPoint(point, esriSegmentExtension.esriNoExtension);

            //Since point was passed in ByValue, we have to modify its values instead.
            //of giving it a new address.
            point.PutCoords(snapPt.X, snapPt.Y);

            return(true);
        }
예제 #28
0
        ///<summary>Flash geometry on the display. The geometry type could be polygon, polyline, point, or multipoint.</summary>
        ///
        ///<param name="geometry"> An IGeometry interface</param>
        ///<param name="color">An IRgbColor interface</param>
        ///<param name="display">An IDisplay interface</param>
        ///<param name="delay">A System.Int32 that is the time im milliseconds to wait.</param>
        ///
        ///<remarks></remarks>
        public static void FlashGeometry(ESRI.ArcGIS.Geometry.IGeometry geometry, ESRI.ArcGIS.Display.IRgbColor color, ESRI.ArcGIS.Display.IDisplay display, System.Int32 delay, IEnvelope envelope)
        {
            if (geometry == null || color == null || display == null)
            {
                return;
            }

            display.StartDrawing(display.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast

            switch (geometry.GeometryType)
            {
            case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
            {
                //Set the flash geometry's symbol.
                ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
                simpleFillSymbol.Color = color;
                ESRI.ArcGIS.Display.ISymbol symbol = simpleFillSymbol as ESRI.ArcGIS.Display.ISymbol;         // Dynamic Cast
                symbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;

                //Flash the input polygon geometry.
                display.SetSymbol(symbol);
                display.DrawPolygon(geometry);
                System.Threading.Thread.Sleep(delay);
                display.DrawPolygon(geometry);
                break;
            }

            case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
            {
                //Set the flash geometry's symbol.
                ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
                simpleLineSymbol.Width = 4;
                simpleLineSymbol.Color = color;
                ESRI.ArcGIS.Display.ISymbol symbol = simpleLineSymbol as ESRI.ArcGIS.Display.ISymbol;         // Dynamic Cast
                symbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;

                //Flash the input polyline geometry.
                display.SetSymbol(symbol);
                display.DrawPolyline(geometry);
                System.Threading.Thread.Sleep(delay);
                display.DrawPolyline(geometry);
                break;
            }

            case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
            {
                //Set the flash geometry's symbol.
                ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbolClass();
                simpleMarkerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle;
                simpleMarkerSymbol.Size  = 12;
                simpleMarkerSymbol.Color = color;
                ESRI.ArcGIS.Display.ISymbol markerSymbol = simpleMarkerSymbol as ESRI.ArcGIS.Display.ISymbol;         // Dynamic Cast
                markerSymbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;

                ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
                simpleLineSymbol.Width = 1;
                simpleLineSymbol.Color = color;
                ESRI.ArcGIS.Display.ISymbol lineSymbol = simpleLineSymbol as ESRI.ArcGIS.Display.ISymbol;         // Dynamic Cast
                lineSymbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;

                //Flash the input polygon geometry.
                display.SetSymbol(markerSymbol);
                display.SetSymbol(lineSymbol);

                ArcMapHelpers.DrawCrossHair(geometry, display, envelope, markerSymbol, lineSymbol);

                //Flash the input point geometry.
                display.SetSymbol(markerSymbol);
                display.DrawPoint(geometry);
                System.Threading.Thread.Sleep(delay);
                display.DrawPoint(geometry);
                break;
            }

            case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryMultipoint:
            {
                //Set the flash geometry's symbol.
                ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbolClass();
                simpleMarkerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle;
                simpleMarkerSymbol.Size  = 12;
                simpleMarkerSymbol.Color = color;
                ESRI.ArcGIS.Display.ISymbol symbol = simpleMarkerSymbol as ESRI.ArcGIS.Display.ISymbol;         // Dynamic Cast
                symbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;

                //Flash the input multipoint geometry.
                display.SetSymbol(symbol);
                display.DrawMultipoint(geometry);
                System.Threading.Thread.Sleep(delay);
                display.DrawMultipoint(geometry);
                break;
            }
            }

            display.FinishDrawing();
        }
예제 #29
0
        private static void DrawCrossHair(ESRI.ArcGIS.Geometry.IGeometry geometry, ESRI.ArcGIS.Display.IDisplay display, IEnvelope extent, ISymbol markerSymbol, ISymbol lineSymbol)
        {
            try
            {
                var point       = geometry as IPoint;
                var numSegments = 10;

                var latitudeMid      = point.Y;//envelope.YMin + ((envelope.YMax - envelope.YMin) / 2);
                var longitudeMid     = point.X;
                var leftLongSegment  = (point.X - extent.XMin) / numSegments;
                var rightLongSegment = (extent.XMax - point.X) / numSegments;
                var topLatSegment    = (extent.YMax - point.Y) / numSegments;
                var bottomLatSegment = (point.Y - extent.YMin) / numSegments;
                var fromLeftLong     = extent.XMin;
                var fromRightLong    = extent.XMax;
                var fromTopLat       = extent.YMax;
                var fromBottomLat    = extent.YMin;
                var av = (ArcMap.Application.Document as IMxDocument).ActiveView;

                var leftPolyline   = new PolylineClass();
                var rightPolyline  = new PolylineClass();
                var topPolyline    = new PolylineClass();
                var bottomPolyline = new PolylineClass();

                leftPolyline.SpatialReference   = geometry.SpatialReference;
                rightPolyline.SpatialReference  = geometry.SpatialReference;
                topPolyline.SpatialReference    = geometry.SpatialReference;
                bottomPolyline.SpatialReference = geometry.SpatialReference;

                var leftPC   = leftPolyline as IPointCollection;
                var rightPC  = rightPolyline as IPointCollection;
                var topPC    = topPolyline as IPointCollection;
                var bottomPC = bottomPolyline as IPointCollection;

                leftPC.AddPoint(new PointClass()
                {
                    X = fromLeftLong, Y = latitudeMid
                });
                rightPC.AddPoint(new PointClass()
                {
                    X = fromRightLong, Y = latitudeMid
                });
                topPC.AddPoint(new PointClass()
                {
                    X = longitudeMid, Y = fromTopLat
                });
                bottomPC.AddPoint(new PointClass()
                {
                    X = longitudeMid, Y = fromBottomLat
                });

                for (int x = 1; x <= numSegments; x++)
                {
                    //Flash the input polygon geometry.
                    display.SetSymbol(markerSymbol);
                    display.SetSymbol(lineSymbol);

                    leftPC.AddPoint(new PointClass()
                    {
                        X = fromLeftLong + leftLongSegment * x, Y = latitudeMid
                    });
                    rightPC.AddPoint(new PointClass()
                    {
                        X = fromRightLong - rightLongSegment * x, Y = latitudeMid
                    });
                    topPC.AddPoint(new PointClass()
                    {
                        X = longitudeMid, Y = fromTopLat - topLatSegment * x
                    });
                    bottomPC.AddPoint(new PointClass()
                    {
                        X = longitudeMid, Y = fromBottomLat + bottomLatSegment * x
                    });

                    // draw
                    display.DrawPolyline(leftPolyline);
                    display.DrawPolyline(rightPolyline);
                    display.DrawPolyline(topPolyline);
                    display.DrawPolyline(bottomPolyline);

                    System.Threading.Thread.Sleep(15);
                    display.FinishDrawing();
                    av.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
                    //av.Refresh();
                    System.Windows.Forms.Application.DoEvents();
                    display.StartDrawing(display.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast
                }
            }
            catch (Exception ex)
            {
            }
        }
예제 #30
0
 /// <summary>
 /// Converts point geometry to geohash
 /// </summary>
 /// <param name="geometry">The input geometry</param>
 /// <returns>geohash string </returns>
 public static string ToGeohash(this ESRI.ArcGIS.Geometry.IGeometry geometry)
 {
     return(geometry.ToGeohash(Constants.DefaultGeohashPrecision));
 }