示例#1
1
        private void axSceneControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ISceneControlEvents_OnMouseDownEvent e)
        {
            IPoint pPoint = null;
            object objOwner = null;
            object objObject = null;

            axSceneControl1.SceneGraph.Locate(axSceneControl1.SceneViewer, e.x, e.y, esriScenePickMode.esriScenePickGeography, true, out pPoint, out objOwner, out objObject);

            ITextElement pTextElement = new TextElementClass();
            pTextElement.Text = "dddddd";

            IGraphicsContainer3D pGCon3D = axSceneControl1.Scene.BasicGraphicsLayer as IGraphicsContainer3D;
            IElement  pElement = new MarkerElementClass();
            IMarkerElement pPointElement = pElement as MarkerElementClass;
            ILineElement pLineElement = pElement as ILineElement;
            ISimpleLineSymbol pLSymbol = new SimpleLineSymbolClass();
            ISimpleMarkerSymbol pMSym = new SimpleMarkerSymbolClass();
            IColor pFromColor = new RgbColorClass();
            IRgbColor pRgbColor = pFromColor as IRgbColor;
            pRgbColor.Red = 255;
            pRgbColor.Green = 0;
            pRgbColor.Blue = 0;
            pMSym.Size = 10;
            pMSym.Color = pFromColor;
            pMSym.Style = esriSimpleMarkerStyle.esriSMSDiamond;
            pPointElement.Symbol = pMSym;
            pLSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
            pElement.Geometry = pPoint;

            pGCon3D.AddElement(pElement as IElement );
            axSceneControl1.Scene.SceneGraph.RefreshViewers();
            IDisplay3D pIDisplay3D = axSceneControl1.Scene.SceneGraph as IDisplay3D ;
            pIDisplay3D.FlashLocation(pPoint);
        }
        protected override void OnClick()
        {
            // Access a feature layer from ArcMap
             IMap map = ArcMap.Document.FocusMap;
            IFeatureLayer featureLayer = map.Layer[0] as IFeatureLayer;
            IFeatureClass featureclass = featureLayer.FeatureClass;

            IRgbColor lineColor = new RgbColorClass();
            lineColor.Red = 255;
            lineColor.Green = 255;
            lineColor.Blue = 0;

            ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass();
            lineSymbol.Color = lineColor;
            lineSymbol.Width = 3.0;

            ISimpleRenderer simpleRenderer = new SimpleRendererClass();
            simpleRenderer.Label = "Taper";
            simpleRenderer.Symbol = lineSymbol as ISymbol;

            IGeoFeatureLayer geoFL = featureLayer as IGeoFeatureLayer;
            geoFL.Renderer = simpleRenderer as IFeatureRenderer;
            ArcMap.Document.ActivatedView.Refresh();
            ArcMap.Document.ActivatedView.PartialRefresh(esriViewDrawPhase.esriViewGeography, geoFL, ArcMap.Document.ActivatedView.Extent);
            ArcMap.Document.UpdateContents();
        }
示例#3
0
 //简单渲染专题图
 private void button1_Click(object sender, EventArgs e)
 {
     //简单填充符号
     ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
     simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSDiagonalCross;
     simpleFillSymbol.Color = getRGB(255, 0, 0);
     //创建边线符号
     ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
     simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDotDot;
     simpleLineSymbol.Color = getRGB(0, 255, 0);
     ISymbol symbol = simpleLineSymbol as ISymbol;
     symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;
     simpleFillSymbol.Outline = simpleLineSymbol;
     ISimpleRenderer simpleRender = new SimpleRendererClass();
     simpleRender.Symbol = simpleFillSymbol as ISymbol;
     simpleRender.Label = "NAME";
     simpleRender.Description = "东丰县行政区域";
     IGeoFeatureLayer geoFeatureLayer;
     geoFeatureLayer = getGeoLayer("东丰县行政区域");
     if (geoFeatureLayer != null)
     {
         geoFeatureLayer.Renderer = simpleRender as IFeatureRenderer;
     }
     this.axMapControl1.Refresh();
 }
示例#4
0
        private ISymbol GetSimpleSymbolBySelector(ISymbol symbolType)
        {
            ISymbolSelector pSymbolSelector = new SymbolSelectorClass();
            ISymbol         symbol          = null;

            if (symbolType is IMarkerSymbol)
            {
                symbol = new SimpleMarkerSymbolClass();
            }
            if (symbolType is ILineSymbol)
            {
                symbol = new SimpleLineSymbolClass();
            }
            if (symbolType is IFillSymbol)
            {
                symbol = new SimpleFillSymbolClass();
            }
            pSymbolSelector.AddSymbol(symbol);
            bool response = pSymbolSelector.SelectSymbol(0);

            if (response)
            {
                symbol = pSymbolSelector.GetSymbolAt(0);
                return(symbol);
            }
            return(null);
        }
示例#5
0
        /// <summary>
        /// 简单渲染
        /// </summary>
        /// <param name="layerName">图层名字</param>
        /// <param name="FillStyle">FillStyle</param>
        /// <param name="pColor">FillColor</param>
        /// <param name="OutLineColor">OutLineColor</param>
        /// <param name="RenderLabel">样式名称注释</param>
        /// <param name="Descripition">描述</param>
        public void createSimpleFillSymbol(string layerName, esriSimpleFillStyle FillStyle, IColor pColor, IColor OutLineColor, string RenderLabel, string Descripition)
        {
            //简单填充符号
            ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
            //可以用符号选择器进行
            simpleFillSymbol.Style = FillStyle;
            simpleFillSymbol.Color = pColor;
            //创建边线符号
            ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
            simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
            simpleLineSymbol.Color = OutLineColor;
            ISymbol symbol = simpleLineSymbol as ISymbol;
            symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;
            simpleFillSymbol.Outline = simpleLineSymbol;

            ISimpleRenderer simpleRender = new SimpleRendererClass();
            simpleRender.Symbol = simpleFillSymbol as ISymbol;
            simpleRender.Label = RenderLabel;
            simpleRender.Description = Descripition;

            IGeoFeatureLayer geoFeatureLayer;
            geoFeatureLayer = getGeoLayer(layerName);
            if (geoFeatureLayer != null)
            {
                geoFeatureLayer.Renderer = simpleRender as IFeatureRenderer;
            }
        }
示例#6
0
        private void algorithmicColorRampToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IMap mmap = axMapControl1.Map;
            IActiveView pActiveView = mmap as IActiveView;

            IGeometry pLine = axMapControl1.TrackLine();

            ISimpleLineSymbol pLineSymbol = new SimpleLineSymbolClass();

            IEnumColors pEnumColors = CreateAlgColorRamp(GetRGB(0, 255, 0), GetRGB(255, 0, 255), 20);
            IColor pColor = pEnumColors.Next();

            pLineSymbol.Color = pColor;
            pLineSymbol.Width = 2;
            pLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;

            IElement element = new LineElementClass();
            element.Geometry = pLine;
            ILineElement pLineElement = element as ILineElement;
            pLineElement.Symbol = pLineSymbol;

            IGraphicsContainer ppGraphicsContainer = mmap as IGraphicsContainer;
            ppGraphicsContainer.AddElement(pLineElement as IElement, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
示例#7
0
        //简单渲染专题图
        private void button1_Click(object sender, EventArgs e)
        {
            //简单填充符号
            ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();

            simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSDiagonalCross;
            simpleFillSymbol.Color = getRGB(255, 0, 0);
            //创建边线符号
            ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();

            simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDotDot;
            simpleLineSymbol.Color = getRGB(0, 255, 0);
            ISymbol symbol = simpleLineSymbol as ISymbol;

            symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;
            simpleFillSymbol.Outline = simpleLineSymbol;
            ISimpleRenderer simpleRender = new SimpleRendererClass();

            simpleRender.Symbol      = simpleFillSymbol as ISymbol;
            simpleRender.Label       = "NAME";
            simpleRender.Description = "东丰县行政区域";
            IGeoFeatureLayer geoFeatureLayer;

            geoFeatureLayer = getGeoLayer("东丰县行政区域");
            if (geoFeatureLayer != null)
            {
                geoFeatureLayer.Renderer = simpleRender as IFeatureRenderer;
            }
            this.axMapControl1.Refresh();
        }
示例#8
0
        public static ISymbol GetASymbolBySymbolType(string SymbolType, IColor aColor)
        {
            if (aColor == null)
            {
                IRgbColor pRgbColor;
                aColor        = new RgbColorClass();
                pRgbColor     = (IRgbColor)aColor;
                pRgbColor.RGB = Information.RGB((int)(VBMath.Rnd(1) * 255), (int)(VBMath.Rnd(1) * 255), (int)(VBMath.Rnd(1) * 255));
            }

            switch (SymbolType)
            {
            case "面状地物符号":
                ISimpleFillSymbol pFillSymbol = new SimpleFillSymbolClass();
                pFillSymbol.Color = aColor;
                return((ISymbol)pFillSymbol);

            case "线状地物符号":
                ILineSymbol pLineSymbol = new SimpleLineSymbolClass();
                pLineSymbol.Width = 1;
                pLineSymbol.Color = aColor;
                return((ISymbol)pLineSymbol);

            case "点状地物符号":
                IMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbolClass();
                pMarkerSymbol.Color = aColor;
                return((ISymbol)pMarkerSymbol);

            default:
                return(null);
            }
        }
示例#9
0
        // Save config and exit.
        private void okButton_Click(object sender, EventArgs e)
        {
            try
            {
                ISimpleFillSymbol selectionSymbol = new SimpleFillSymbolClass();
                selectionSymbol.Color = selFillColorPaletteButton.Color;
                selectionSymbol.Color.Transparency = Convert.ToByte(255 - Convert.ToDouble(selTranNumericUpDown.Value) * 2.55);
                ISimpleLineSymbol selectionOutlineSymbol = new SimpleLineSymbolClass();
                selectionOutlineSymbol.Color = selOutlineColorPaletteButton.Color;
                selectionOutlineSymbol.Width = Convert.ToDouble(selOutlineWidthNumericUpDown.Value);
                selectionSymbol.Outline = selectionOutlineSymbol;
                Config.SelectionSmbol = selectionSymbol;

                ISimpleFillSymbol editSymbol = new SimpleFillSymbolClass();
                editSymbol.Color = editFillColorColorPaletteButton.Color;
                editSymbol.Color.Transparency = Convert.ToByte(255 - Convert.ToDouble(editTranNumericUpDown.Value) * 2.55);
                ISimpleLineSymbol editOutlineSymbol = new SimpleLineSymbolClass();
                editOutlineSymbol.Color = editOutlineColorPaletteButton.Color;
                editOutlineSymbol.Width = Convert.ToDouble(editOutlineWidthNumericUpDown.Value);
                editSymbol.Outline = editOutlineSymbol;
                Config.EditSymbol = editSymbol;
                Config.CustormEditColor = editCustomCheckBox.Checked;

                Config.Save();
                Editor.Refresh();
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Unfortunately, the application meets an error.\n\nSource: {0}\nSite: {1}\nMessage: {2}", ex.Source, ex.TargetSite, ex.Message), "Error");
            }
        }
示例#10
0
        private void 生成等高线ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //获取TIN图层
            ITinLayer pTinLayer           = axSceneControl1.Scene.get_Layer(0) as ITinLayer;
            ITin      pTin                = pTinLayer.Dataset as ITin;
            string    contourFileName     = pTinLayer.Name + "_Contour";
            string    contourFileName_shp = workSpaceName + @"/" + contourFileName + ".shp";

            if (System.IO.File.Exists(contourFileName_shp))
            {
                System.IO.File.Delete(contourFileName_shp);
                System.IO.File.Delete(System.IO.Path.ChangeExtension(contourFileName_shp, ".dbf"));
                System.IO.File.Delete(System.IO.Path.ChangeExtension(contourFileName_shp, ".shx"));
            }
            IFeatureClass contourFeatureClass = Create_ContourLine(pTin, workSpaceName, contourFileName);
            //添加等高线图层
            IFeatureLayer pFeatureLayer = new FeatureLayerClass();

            pFeatureLayer.FeatureClass = contourFeatureClass;
            IGeoFeatureLayer pGeoFeatureLayer = pFeatureLayer as IGeoFeatureLayer;

            pGeoFeatureLayer.DisplayAnnotation = true;
            pGeoFeatureLayer.DisplayField      = "Contour";
            pGeoFeatureLayer.Name = contourFileName + "_Contour";
            //设置线样式
            ILineSymbol pLineSymbol = new SimpleLineSymbolClass();

            pLineSymbol.Color = Get_RGBColor(100, 50, 30);
            pLineSymbol.Width = 2;
            ISimpleRenderer pRender = pGeoFeatureLayer.Renderer as ISimpleRenderer;

            pRender.Symbol = pLineSymbol as ISymbol;
            axMapControl1.AddLayer(pFeatureLayer as ILayer);
        }
示例#11
0
        private void button4_Click(object sender, EventArgs e)
        {
            int    selectedFieldIndex            = m_pTarFeatureLayer.FeatureClass.Fields.FindField(comboBox1.SelectedItem.ToString());
            IField selectedField                 = m_pTarFeatureLayer.FeatureClass.Fields.get_Field(selectedFieldIndex);
            IUniqueValueRenderer unqValueRenderr = new UniqueValueRendererClass();

            #region UniqueValueRenderer需要定义字段数,字段名,并最后添加字段中每一种值对应的渲染方式(AddValue)
            unqValueRenderr.FieldCount = 1;
            unqValueRenderr.set_Field(0, selectedField.Name);//0是干什么的?
            #endregion
            IAlgorithmicColorRamp acr = new AlgorithmicColorRampClass();
            acr.FromColor = m_pFillColor;
            acr.ToColor   = m_pOutlineColor;
            acr.Size      = m_pTarFeatureLayer.FeatureClass.FeatureCount(null);
            bool isOK;
            acr.CreateRamp(out isOK);
            #region 很迷,不知道为什么直接acr.colors.next遍历不了colorramp
            IEnumColors enumColor = acr.Colors;
            IColor      curColor  = enumColor.Next();
            #endregion
            #region 开始遍历图层获取所有feature
            for (int i = 0; i < m_pTarFeatureLayer.FeatureClass.FeatureCount(null); i++)
            {
                IFeature curFeature = m_pTarFeatureLayer.FeatureClass.GetFeature(i);
                switch (m_pTarFeatureLayer.FeatureClass.ShapeType)
                {
                case esriGeometryType.esriGeometryPolygon:
                {
                    ISimpleFillSymbol sfs = new SimpleFillSymbolClass();
                    sfs.Color = curColor;
                    unqValueRenderr.AddValue(curFeature.get_Value(selectedFieldIndex).ToString(), "", sfs as ISymbol);
                    break;
                }

                case esriGeometryType.esriGeometryPoint:
                {
                    ISimpleMarkerSymbol sms = new SimpleMarkerSymbolClass
                    {
                        Color = curColor
                    };
                    unqValueRenderr.AddValue(curFeature.get_Value(selectedFieldIndex).ToString(), "", sms as ISymbol);
                    break;
                }

                case esriGeometryType.esriGeometryPolyline:
                {
                    ISimpleLineSymbol sls = new SimpleLineSymbolClass();
                    sls.Color = curColor;
                    unqValueRenderr.AddValue(curFeature.get_Value(selectedFieldIndex).ToString(), "", sls as ISymbol);
                    break;
                }
                }
                curColor = enumColor.Next();
            }
            m_pTarGeoFeatureLayer.Renderer = unqValueRenderr as IFeatureRenderer;
            frmMainOper(OperationType.RefreshMapCtrl);
            frmMainOper(OperationType.UpdateTOCCtrl);
            #endregion
        }
示例#12
0
        private ISymbol CreateBikeRouteSymbol()
        {
            IColor color = (IColor)ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(0, 90, 250));
            ICharacterMarkerSymbol charMarkerSymbol = new CharacterMarkerSymbolClass();

            charMarkerSymbol.Color          = color;
            charMarkerSymbol.Font           = ESRI.ArcGIS.ADF.Connection.Local.Converter.ToStdFont(new Font("ESRI Default Marker", 17.0f, FontStyle.Bold));
            charMarkerSymbol.CharacterIndex = 189;
            charMarkerSymbol.Size           = 17;

            IMarkerLineSymbol markerLineSymbol = new MarkerLineSymbolClass();

            markerLineSymbol.Color        = color;
            markerLineSymbol.Width        = 17.0;
            markerLineSymbol.MarkerSymbol = (IMarkerSymbol)charMarkerSymbol;

            // Makes a new Cartographic Line symbol and sets its properties
            ICartographicLineSymbol cartographicLineSymbol = markerLineSymbol as ICartographicLineSymbol;

            // In order to set additional properties like offsets and dash patterns we must create an ILineProperties object
            ILineProperties lineProperties = cartographicLineSymbol as ILineProperties;

            lineProperties.Offset = 0;

            // Here's how to do a template for the pattern of marks and gaps
            double[] hpe = new double[4];
            hpe[0] = 0;
            hpe[1] = 39;
            hpe[2] = 1;
            hpe[3] = 0;

            ITemplate template = new TemplateClass();

            template.Interval = 1;
            for (int i = 0; i < hpe.Length; i = i + 2)
            {
                template.AddPatternElement(hpe[i], hpe[i + 1]);
            }
            lineProperties.Template = template;

            // Set the basic and cartographic line properties
            cartographicLineSymbol.Color = color;

            color = (IColor)ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(0, 220, 100));

            // create a simple line
            ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();

            simpleLineSymbol.Color = color;
            simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
            simpleLineSymbol.Width = 1.2;

            IMultiLayerLineSymbol multiLayerLineSymbol = new MultiLayerLineSymbolClass();

            multiLayerLineSymbol.AddLayer((ILineSymbol)cartographicLineSymbol);
            multiLayerLineSymbol.AddLayer((ILineSymbol)simpleLineSymbol);

            return(multiLayerLineSymbol as ISymbol);
        }
示例#13
0
        /// <summary>
        /// 根据mapcontrol绘制的多边形在样本表格中生成样本
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BegineCreateSample(IGeometry SampleGeometry)
        {
            IPolygon polygon = (IPolygon)SampleGeometry;

            if (SampleLayerCombox.Tag != null)
            {
                //计算像元数
                IArea        area        = polygon as IArea;
                IGeoDataset  geodataset  = SampleLayerCombox.Tag as IGeoDataset;
                IRaster      raster      = geodataset as IRaster;
                IRasterProps rasterprops = raster as IRasterProps;
                double       pixelcount  = System.Math.Abs(area.Area) / (rasterprops.MeanCellSize().X *rasterprops.MeanCellSize().Y);

                //生成表格
                if (SC_dataGridView.ColumnCount == 0)
                {
                    SC_dataGridView.Columns.Add("ID", "ID");
                    SC_dataGridView.Columns.Add("name", "样本名称");
                    SC_dataGridView.Columns.Add("value", "样本值");
                    SC_dataGridView.Columns.Add("color", "样本颜色");
                    SC_dataGridView.Columns.Add("count", "像元数(近似值)");
                }
                SC_dataGridView.Rows.Add();
                SC_dataGridView.Rows[SC_dataGridView.Rows.Count - 1].Cells["ID"].Value    = SC_dataGridView.Rows.Count;
                SC_dataGridView.Rows[SC_dataGridView.Rows.Count - 1].Cells["name"].Value  = "样本" + (SC_dataGridView.Rows.Count).ToString();
                SC_dataGridView.Rows[SC_dataGridView.Rows.Count - 1].Cells["value"].Value = (SC_dataGridView.Rows.Count).ToString();
                SC_dataGridView.Rows[SC_dataGridView.Rows.Count - 1].Cells["count"].Value = Convert.ToInt32(pixelcount) + 1;

                //生成随机色
                Random random    = new Random();
                Color  linecolor = new Color();
                linecolor = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255));
                //填充单元格颜色
                SC_dataGridView.Rows[SC_dataGridView.Rows.Count - 1].Cells["color"].Style.BackColor = linecolor;
                //将polygon存放到gridview表color列对应的tag中
                SC_dataGridView.Rows[SC_dataGridView.Rows.Count - 1].Cells["color"].Tag = polygon;

                //新建绘制图形的填充符号
                IRgbColor arccolor = new RgbColorClass();
                arccolor.RGB = linecolor.B * 65536 + linecolor.G * 256 + linecolor.R;
                ILineSymbol outline = new SimpleLineSymbolClass();
                outline.Width = 3;
                outline.Color = arccolor;
                IFillSymbol       fillsymbol = new SimpleFillSymbolClass();
                ISimpleFillSymbol pFillsyl   = fillsymbol as ISimpleFillSymbol;
                pFillsyl.Style     = esriSimpleFillStyle.esriSFSNull;
                fillsymbol.Outline = outline;

                IPolygonElement PolygonElement = new PolygonElementClass();
                IElement        pElement       = PolygonElement as IElement;
                pElement.Geometry = SampleGeometry;

                IFillShapeElement FillShapeElement = pElement as IFillShapeElement;
                FillShapeElement.Symbol = fillsymbol;
                IGraphicsContainer pGraphicsContainer = main.getMapControl().Map as IGraphicsContainer;
                pGraphicsContainer.AddElement((IElement)PolygonElement, 0);
                main.getMapControl().ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            }
        }
示例#14
0
 public static ISimpleLineSymbol get_SimpleLineSymbol(IColor color, double width, esriSimpleLineStyle style)
 {
     ISimpleLineSymbol theReturn = new SimpleLineSymbolClass();
     theReturn.Color = color;
     theReturn.Style = style;
     theReturn.Width = width;
     return theReturn;
 }
示例#15
0
        public static ILineSymbol GetSimpleLineSymbol(Double width, IColor color)
        {
            ILineSymbol lineSymbol = new SimpleLineSymbolClass();

            lineSymbol.Width = width;
            lineSymbol.Color = color;//红线
            return(lineSymbol);
        }
示例#16
0
 public static ISimpleLineSymbol GetSimpleLineSymbol(IRgbColor rgbColor,double width)
 {
     var simpleLineSymbol = new SimpleLineSymbolClass();
     simpleLineSymbol.Color = rgbColor;
     simpleLineSymbol.Width = width;
     simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
     return simpleLineSymbol;
 }
示例#17
0
        /// <summary>
        /// 绘制pGeometry的图形
        /// </summary>
        /// <param name="pGeometry"> 几何体实例</param>
        /// <param name="pScreenDisplay"> 当前屏幕显示</param>
        private void drawgeometryXOR(IPolygon pPolygon, IScreenDisplay pScreenDisplay)
        {
            IFillSymbol       pFillSymbol = new SimpleFillSymbolClass();
            ISimpleLineSymbol pLineSymbol = new SimpleLineSymbolClass();

            try
            {
                //颜色对象
                IRgbColor pRGBColor = new RgbColorClass();
                pRGBColor.UseWindowsDithering = false;
                pRGBColor.Red   = 45;
                pRGBColor.Green = 45;
                pRGBColor.Blue  = 45;

                //填充符号以及画笔
                ISymbol pSymbol = pFillSymbol as ISymbol;
                pSymbol.ROP2      = esriRasterOpCode.esriROPXOrPen;
                pFillSymbol.Color = pRGBColor;

                //边缘线颜色以及画笔
                ISymbol pLSymbol = pLineSymbol as ISymbol;
                pLSymbol.ROP2     = esriRasterOpCode.esriROPXOrPen;
                pRGBColor.Red     = 145;
                pRGBColor.Green   = 145;
                pRGBColor.Blue    = 145;
                pLineSymbol.Color = (IColor)pRGBColor;

                pLineSymbol.Width   = 0.8;
                pLineSymbol.Style   = esriSimpleLineStyle.esriSLSSolid;
                pFillSymbol.Outline = pLineSymbol;

                pScreenDisplay.StartDrawing(m_pScreenDisplay.hDC, -1);  //esriScreenCache.esriNoScreenCache -1
                pScreenDisplay.SetSymbol(pSymbol);

                //不存在已画出的多边形
                if (pPolygon != null)
                {
                    pScreenDisplay.DrawPolygon(pPolygon);
                    m_pPolygon = pPolygon;
                }
                //存在已画出的多边形
                else
                {
                    if (m_pPolygon != null)
                    {
                        pScreenDisplay.DrawPolygon(m_pPolygon);
                    }
                }

                pScreenDisplay.FinishDrawing();
            }
            catch (Exception ex)
            {
                MessageBox.Show("绘制缓冲范围出错:" + ex.Message, "提示");
                pFillSymbol = null;
            }
        }
        //.................................................
        //.................................................
        //.................................................
        private void AssignColorRamp(string fieldname, List <RiskRankingRange> pRiskRankingRanges)
        {
            // Get Statistics Values for the Selected Field
            GetRankingStatistics(fieldname);
            if (_minriskvalue >= _maxriskvalue)
            {
                return;
            }
            if (pRiskRankingRanges.Count == 0)
            {
                return;
            }
            if (m_styleGalleryItem == null)
            {
                return;
            }
            if (m_featureLayer == null)
            {
                return;
            }
            m_classBreaksRenderer.Field        = fieldname;
            m_classBreaksRenderer.BreakCount   = pRiskRankingRanges.Count;
            m_classBreaksRenderer.MinimumBreak = 0;

            //Calculate the class interval by a simple mean value
            double interval = (_maxriskvalue - _minriskvalue) / pRiskRankingRanges.Count;

            //Get the color ramp
            IColorRamp colorRamp = (IColorRamp)m_styleGalleryItem.Item;

            //Set the size of the color ramp and recreate it
            colorRamp.Size = Convert.ToInt32(pRiskRankingRanges.Count);
            bool createRamp;

            colorRamp.CreateRamp(out createRamp);

            //Get the enumeration of colors from the color ramp
            IEnumColors enumColors = colorRamp.Colors;

            enumColors.Reset();
            double currentBreak = m_classBreaksRenderer.MinimumBreak;

            ISimpleLineSymbol simpleLineSymbol;

            //Loop through each class break
            for (int i = 0; i <= pRiskRankingRanges.Count - 1; i++)
            {
                //Set class break
                m_classBreaksRenderer.set_Break(i, currentBreak);
                //Create simple fill symbol and set color
                simpleLineSymbol       = new SimpleLineSymbolClass();
                simpleLineSymbol.Color = enumColors.Next();
                //Add symbol to renderer
                m_classBreaksRenderer.set_Symbol(i, (ISymbol)simpleLineSymbol);
                currentBreak += interval;
            }
        }
        private ISymbol GetSymbolBySymbolSelector(esriGeometryType geometryType)
        {
            try
            {
                ISymbolSelector pSymbolSelector = new SymbolSelectorClass();
                ISymbol         symbol          = null;
                switch (geometryType)
                {
                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
                    symbol = new SimpleMarkerSymbolClass();
                    break;

                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
                    symbol = new SimpleLineSymbolClass();
                    break;

                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
                    symbol = new SimpleFillSymbolClass();
                    break;

                default:
                    break;
                }
                pSymbolSelector.AddSymbol(symbol);
                bool response = pSymbolSelector.SelectSymbol(0);
                if (response)
                {
                    symbol = pSymbolSelector.GetSymbolAt(0);
                    return(symbol);
                }
                return(null);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                //自定义
                ISymbol symbol = null;
                switch (geometryType)
                {
                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
                    symbol = new SimpleMarkerSymbolClass();
                    break;

                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
                    symbol = new SimpleLineSymbolClass();
                    break;

                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
                    symbol = new SimpleFillSymbolClass();
                    break;

                default:
                    break;
                }
                return(symbol);
            }
        }
示例#20
0
        private void SetPolygonMarkerSymbol(ISymbol symbol)
        {
            SimpleFillSymbolClass simpleFillSymbol = symbol as SimpleFillSymbolClass;
            SimpleLineSymbolClass simpleLineSymbol = new SimpleLineSymbolClass();

            SetPolylineMarkerSymbol(simpleLineSymbol as ISymbol);
            simpleFillSymbol.Outline = simpleLineSymbol;
            simpleFillSymbol.Color   = SymbolUtil.GetColor(222, 222, 222);
        }
示例#21
0
        public static ILineSymbol CreateSimpleLineSymbol(Color lineColor, double width, esriSimpleLineStyle eStyle)
        {
            SimpleLineSymbolClass class2 = new SimpleLineSymbolClass();

            class2.Color = ColorHelper.CreateColor(lineColor);
            class2.Style = eStyle;
            class2.Width = Math.Abs(width);
            return(class2);
        }
示例#22
0
        /// <summary>
        /// ZQ 2011 1129  modify
        /// </summary>
        /// <param name="pPolygon"></param>
        private void drawgeometryXOR(IGeometry pPolygon)
        {
            //联动
            //this.sliderBuffer.Value = Convert.ToInt32(dblBuffLen.Text);
            //获得缓冲范围

            IScreenDisplay    pScreenDisplay = m_MapControl.ActiveView.ScreenDisplay;
            ISimpleFillSymbol pFillSymbol    = new SimpleFillSymbolClass();
            ISimpleLineSymbol pLineSymbol    = new SimpleLineSymbolClass();

            try
            {
                //颜色对象
                IRgbColor pRGBColor = new RgbColorClass();
                pRGBColor.UseWindowsDithering = false;
                ISymbol pSymbol = (ISymbol)pFillSymbol;
                pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;

                pRGBColor.Red     = 255;
                pRGBColor.Green   = 170;
                pRGBColor.Blue    = 0;
                pLineSymbol.Color = pRGBColor;

                pLineSymbol.Width   = 1.0;
                pLineSymbol.Style   = esriSimpleLineStyle.esriSLSSolid;
                pFillSymbol.Outline = pLineSymbol;

                pFillSymbol.Color = pRGBColor;
                pFillSymbol.Style = esriSimpleFillStyle.esriSFSDiagonalCross;

                pScreenDisplay.StartDrawing(pScreenDisplay.hDC, -1);  //esriScreenCache.esriNoScreenCache -1
                pScreenDisplay.SetSymbol(pSymbol);

                //不存在已画出的多边形
                if (pPolygon != null)
                {
                    pScreenDisplay.DrawPolygon(pPolygon);
                    m_Polygon = pPolygon;
                }
                //存在已画出的多边形
                else
                {
                    if (m_Polygon != null)
                    {
                        pScreenDisplay.DrawPolygon(m_Polygon);
                    }
                }

                pScreenDisplay.FinishDrawing();
            }
            catch (Exception ex)
            {
                MessageBox.Show("绘制缓冲范围出错:" + ex.Message, "提示");
                pFillSymbol = null;
            }
        }
示例#23
0
        private void DrawLineOnActiveView(List <int> lstIndices, double[][] arrValue, IActiveView pActiveView)
        {
            try
            {
                int intLstCnt = lstIndices.Count;

                IGraphicsContainer pGraphicContainer = pActiveView.GraphicsContainer;
                pGraphicContainer.DeleteAllElements();

                IRgbColor pRgbColor = m_pSnippet.getRGB(0, 255, 255);
                //IRgbColor pRgbColor = new RgbColorClass();
                //pRgbColor.Red = 0;
                //pRgbColor.Green = 255;
                //pRgbColor.Blue = 255;
                //pRgbColor.Transparency = 255;


                ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass();
                pSimpleLineSymbol.Width = 2;
                pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
                pSimpleLineSymbol.Color = pRgbColor;



                for (int i = 0; i < intLstCnt; i++)
                {
                    int      intIdx      = lstIndices[i];
                    double[] arrSelValue = arrValue[intIdx];
                    //drawing a polyline
                    IPoint FromP = new PointClass();
                    FromP.X = arrSelValue[0]; FromP.Y = arrSelValue[1];

                    IPoint ToP = new PointClass();
                    ToP.X = arrSelValue[2]; ToP.Y = arrSelValue[3];

                    IPolyline        polyline  = new PolylineClass();
                    IPointCollection pointColl = polyline as IPointCollection;
                    pointColl.AddPoint(FromP);
                    pointColl.AddPoint(ToP);

                    IElement     pElement     = new LineElementClass();
                    ILineElement pLineElement = (ILineElement)pElement;
                    pLineElement.Symbol = pSimpleLineSymbol;
                    pElement.Geometry   = polyline;

                    pGraphicContainer.AddElement(pElement, 0);
                }

                pActiveView.Refresh();
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
示例#24
0
        private void 给出可测区域ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IGeometry          buffer;
            ISelection         pSeletion         = axMapControl1.Map.FeatureSelection;
            IEnumFeature       pEnumFeature      = (IEnumFeature)pSeletion;
            IGraphicsContainer graphicsContainer = axMapControl1.ActiveView.GraphicsContainer;

            //graphicsContainer.DeleteAllElements();
            IFeature pFeature       = pEnumFeature.Next(); //选择集
            double   bufferDistance = GlobalData.dist;

            if (bufferDistance <= 0.0)
            {
                MessageBox.Show("距离设置错误");
                return;
            }


            while (pFeature != null)
            {
                ITopologicalOperator topoOperator = pFeature.Shape as ITopologicalOperator;
                buffer       = topoOperator.Buffer(bufferDistance);
                topoOperator = buffer as ITopologicalOperator;
                IGeometry result;
                if (rectpElement != null)
                {
                    topoOperator.Clip(rectpElement.Geometry.Envelope);
                }
                IElement element = new PolygonElementClass();
                element.Geometry = buffer;

                //创建矩形轮廓的样式
                ILineSymbol linesymbol = new SimpleLineSymbolClass();
                linesymbol.Width = 2;

                IRgbColor rgbColor = new RgbColorClass();
                rgbColor.Red          = 65;
                rgbColor.Green        = 105;
                rgbColor.Blue         = 225;
                rgbColor.Transparency = 255;
                linesymbol.Color      = rgbColor;

                IFillSymbol fillsymbol = new SimpleFillSymbolClass();

                rgbColor.Transparency = 0;
                fillsymbol.Color      = rgbColor;
                fillsymbol.Outline    = linesymbol;

                IFillShapeElement fillshapeElement = element as IFillShapeElement;
                fillshapeElement.Symbol = fillsymbol;
                // 添加绘图元素
                graphicsContainer.AddElement(element, 0);
                pFeature = pEnumFeature.Next();
            }
            axMapControl1.Refresh();
        }
        private ISimpleLineSymbol GetSimpleLineSymbol(IRgbColor pRgbColor, double fdblWidth,
                                                      esriSimpleLineStyle pesriSimpleLineStyle)
        {
            ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass();

            pSimpleLineSymbol.Color = pRgbColor as IColor;
            pSimpleLineSymbol.Width = fdblWidth;
            pSimpleLineSymbol.Style = pesriSimpleLineStyle;
            return(pSimpleLineSymbol);
        }
示例#26
0
 /// <summary>
 /// 地图控件绘制点、线、面元素操作
 /// </summary>
 /// <param name="mapControl"></param>
 public MapCtrlDrawElement(AxMapControl mapControl)
 {
     MapControl              = mapControl;
     DrawElementType         = EDrawElementType.None;
     MapControl.OnMouseDown += MapControl_OnMouseDown;
     FillSymbol              = new SimpleFillSymbolClass();
     LineSymbol              = new SimpleLineSymbolClass();
     MarkerSymbol            = new SimpleMarkerSymbolClass();
     TextSymbol              = new TextSymbolClass();
 }
示例#27
0
        public static ILineSymbol CreateLineSymbol(IRgbColor color, double width, esriSimpleLineStyle estyle)
        {
            ISimpleLineSymbol pSymbol = new SimpleLineSymbolClass();

            pSymbol.Color = color as IColor;
            pSymbol.Width = width;
            pSymbol.Style = estyle;

            return(pSymbol);
        }
示例#28
0
        /// <summary>
        /// 绘制pGeometry的图形
        /// </summary>
        /// <param name="pGeometry"> 几何体实例</param>
        /// <param name="pScreenDisplay"> 当前屏幕显示</param>
        private void drawgeometryXOR(IPolygon pPolygon, IScreenDisplay pScreenDisplay)
        {
            if (this.IsDisposed && m_bOk == false)//如果窗体关闭或者取消 就不绘制 xisheng 2011.06.28
            {
                return;
            }
            ISimpleFillSymbol pFillSymbol = new SimpleFillSymbolClass();
            ISimpleLineSymbol pLineSymbol = new SimpleLineSymbolClass();

            try
            {
                //颜色对象
                IRgbColor pRGBColor = new RgbColorClass();
                pRGBColor.UseWindowsDithering = false;
                ISymbol pSymbol = (ISymbol)pFillSymbol;
                pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;

                pRGBColor.Red     = 255;
                pRGBColor.Green   = 170;
                pRGBColor.Blue    = 0;
                pLineSymbol.Color = pRGBColor;

                pLineSymbol.Width   = 0.8;
                pLineSymbol.Style   = esriSimpleLineStyle.esriSLSSolid;
                pFillSymbol.Outline = pLineSymbol;

                pFillSymbol.Color = pRGBColor;
                pFillSymbol.Style = esriSimpleFillStyle.esriSFSDiagonalCross;

                pScreenDisplay.StartDrawing(m_pScreenDisplay.hDC, -1);  //esriScreenCache.esriNoScreenCache -1
                pScreenDisplay.SetSymbol(pSymbol);

                //不存在已画出的多边形
                if (pPolygon != null)
                {
                    pScreenDisplay.DrawPolygon(pPolygon);
                    m_pPolygon = pPolygon;
                }
                //存在已画出的多边形
                else
                {
                    if (m_pPolygon != null)
                    {
                        pScreenDisplay.DrawPolygon(m_pPolygon);
                    }
                }

                pScreenDisplay.FinishDrawing();
            }
            catch (Exception ex)
            {
                MessageBox.Show("绘制缓冲范围出错:" + ex.Message, "提示");
                pFillSymbol = null;
            }
        }
示例#29
0
        private static IUniqueValueRenderer GenerateUniqueValueRenderer(IFeatureLayer featureLayer)
        {
            IFeatureWorkspace featureWorkspace = ((IDataset)featureLayer.FeatureClass).Workspace as IFeatureWorkspace;
            ITable            table            = featureWorkspace.OpenTable(TableName);

            string             relClassName = string.Format("{0}_{1}", ((IDataset)featureLayer.FeatureClass).Name, ((IDataset)table).Name);
            IRelationshipClass relClass     = featureWorkspace.OpenRelationshipClass(relClassName);

            IDisplayRelationshipClass displayRelClass = featureLayer as IDisplayRelationshipClass;

            if (displayRelClass == null)
            {
                return(null);
            }
            displayRelClass.DisplayRelationshipClass(relClass, esriJoinType.esriLeftOuterJoin);

            IUniqueValueRenderer uvRenderer = new UniqueValueRendererClass {
                FieldCount = 1
            };

            uvRenderer.Field[0] = string.Format("{0}.{1}", ((IDataset)table).Name, JoinField);

            IFeatureCursor      cursor         = ((IGeoFeatureLayer)featureLayer).SearchDisplayFeatures(null, true);
            DataStatisticsClass dataStatistics = new DataStatisticsClass
            {
                Field  = uvRenderer.Field[0],
                Cursor = cursor as ICursor
            };

            IEnumerator pEnumerator = dataStatistics.UniqueValues;

            pEnumerator.Reset();

            Random random = new Random();

            while (pEnumerator.MoveNext())
            {
                string value = Convert.ToString(pEnumerator.Current);

                RgbColorClass fillColor = new RgbColorClass
                {
                    Red   = random.Next(0, 255),
                    Green = random.Next(0, 255),
                    Blue  = random.Next(0, 255)
                };

                ISimpleLineSymbol fillSymbol = new SimpleLineSymbolClass {
                    Color = fillColor, Width = 2
                };
                uvRenderer.AddValue(value, "ZONE", fillSymbol as ISymbol);
            }

            Marshal.ReleaseComObject(cursor);
            return(uvRenderer);
        }
示例#30
0
        private void UCMap_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e)
        {
            if (scaleUpdated != null)
            {
                scaleUpdated(MapScale);
            }

            ucMapNavigate1.MapScale = (int)base.MapScale;

            // 得到新范围
            IEnvelope          pEnv = (IEnvelope)e.newEnvelope;
            IGraphicsContainer pGra = this.Map as IGraphicsContainer;
            IActiveView        pAv  = pGra as IActiveView;

            //在绘制前,清除axMapControl2中的任何图形元素
            pGra.DeleteAllElements();
            IRectangleElement pRectangleEle = new RectangleElementClass();
            IElement          pEle          = pRectangleEle as IElement;

            pEle.Geometry = pEnv;


            //设置鹰眼图中的红线框

            IRgbColor pColor = new RgbColorClass();

            pColor.Red          = 255;
            pColor.Green        = 0;
            pColor.Blue         = 0;
            pColor.Transparency = 255;

            //产生一个线符号对象
            ILineSymbol pOutline = new SimpleLineSymbolClass();

            pOutline.Width = 1;
            pOutline.Color = pColor;

            //设置颜色属性
            pColor              = new RgbColorClass();
            pColor.Red          = 255;
            pColor.Green        = 0;
            pColor.Blue         = 0;
            pColor.Transparency = 0;

            //设置填充符号的属性
            IFillSymbol pFillSymbol = new SimpleFillSymbolClass();

            pFillSymbol.Color   = pColor;
            pFillSymbol.Outline = pOutline;
            IFillShapeElement pFillShapeEle = pEle as IFillShapeElement;

            pFillShapeEle.Symbol = pFillSymbol;
            pGra.AddElement((IElement)pFillShapeEle, 0);
            pAv.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
示例#31
0
        private void axSceneControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ISceneControlEvents_OnMouseDownEvent e)
        {
            ICamera   pCamera = this.axSceneControl1.Camera;
            IPoint    point   = pCamera.Target;
            IEnvelope pEnv    = new EnvelopeClass();

            pEnv.XMax = point.X + 2;
            pEnv.XMin = point.X - 2;
            pEnv.YMax = point.Y + 2;
            pEnv.YMin = point.Y - 2;

            IRectangleElement pRectangleEle = new RectangleElementClass();
            IElement          pEle          = pRectangleEle as IElement;

            pEle.Geometry = pEnv;

            //设置线框的边线对象,包括颜色和线宽
            IRgbColor pColor = new RgbColorClass();

            pColor.Red          = 238;
            pColor.Green        = 99;
            pColor.Blue         = 99;
            pColor.Transparency = 255;
            // 产生一个线符号对象
            ILineSymbol pOutline = new SimpleLineSymbolClass();

            pOutline.Width = 1;
            pOutline.Color = pColor;

            // 设置颜色属性
            pColor.Red          = 238;
            pColor.Green        = 99;
            pColor.Blue         = 99;
            pColor.Transparency = 0;

            // 设置线框填充符号的属性
            IFillSymbol pFillSymbol = new SimpleFillSymbolClass();

            pFillSymbol.Color   = pColor;
            pFillSymbol.Outline = pOutline;
            IFillShapeElement pFillShapeEle = pEle as IFillShapeElement;

            pFillShapeEle.Symbol = pFillSymbol;

            // 得到鹰眼视图中的图形元素容器
            IGraphicsContainer pGra = axMapControl1.Map as IGraphicsContainer;
            IActiveView        pAv  = pGra as IActiveView;

            // 在绘制前,清除 axMapControl1 中的任何图形元素
            pGra.DeleteAllElements();
            // 鹰眼视图中添加线框
            pGra.AddElement((IElement)pFillShapeEle, 0);
            // 刷新鹰眼
            pAv.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
示例#32
0
        /// <summary>
        /// 根据Geometry类型生成一个默认符号
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public ISymbol GetDefaultSymbol(esriGeometryType type)
        {
            ISymbol sym = null;

            IRgbColor mCor = new RgbColorClass();

            mCor.Red   = 0;
            mCor.Blue  = 0;
            mCor.Green = 0;

            IRgbColor lCor = new RgbColorClass();

            mCor.Red   = 0;
            lCor.Blue  = 0;
            mCor.Green = 0;

            IRgbColor fCor = new RgbColorClass();

            mCor.Red   = 0;
            fCor.Blue  = 0;
            mCor.Green = 0;

            IMarkerSymbol mark = new SimpleMarkerSymbolClass();

            mark.Color = mCor;
            mark.Size  = 8;

            ILineSymbol line = new SimpleLineSymbolClass();

            line.Width = 1.5;
            line.Color = lCor;

            IFillSymbol fill = new SimpleFillSymbolClass();

            fill.Color   = fCor;
            fill.Outline = line;

            switch (type)
            {
            case esriGeometryType.esriGeometryPoint:
                sym = (ISymbol)mark;
                break;

            case esriGeometryType.esriGeometryPolyline:
                sym = (ISymbol)line;
                break;

            case esriGeometryType.esriGeometryPolygon:
                sym = (ISymbol)fill;
                //sym = (ISymbol)line;
                break;
            }

            return(sym);
        }
        private void axMapControl1_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e)
        {
            // 得到新范围
            IEnvelope pEnvelope = (IEnvelope)e.newEnvelope;

            IGraphicsContainer pGraphicsContainer = axMapControl2.Map as IGraphicsContainer;

            IActiveView pActiveView = pGraphicsContainer as IActiveView;

            //在绘制前,清除axMapControl2中的任何图形元素
            pGraphicsContainer.DeleteAllElements();

            IRectangleElement pRectangleEle = new RectangleElementClass();
            IElement          pElement      = pRectangleEle as IElement;

            pElement.Geometry = pEnvelope;

            //设置鹰眼图中的红线框

            IRgbColor pColor = new RgbColorClass();

            pColor.Red          = 255;
            pColor.Green        = 0;
            pColor.Blue         = 0;
            pColor.Transparency = 255;

            //产生一个线符号对象

            ILineSymbol pOutline = new SimpleLineSymbolClass();

            pOutline.Width = 3;
            pOutline.Color = pColor;

            //设置颜色属性

            pColor              = new RgbColorClass();
            pColor.Red          = 255;
            pColor.Green        = 0;
            pColor.Blue         = 0;
            pColor.Transparency = 0;

            //设置填充符号的属性

            IFillSymbol pFillSymbol = new SimpleFillSymbolClass();

            pFillSymbol.Color   = pColor;
            pFillSymbol.Outline = pOutline;
            IFillShapeElement pFillShapeEle = pElement as IFillShapeElement;

            pFillShapeEle.Symbol = pFillSymbol;
            pGraphicsContainer.AddElement((IElement)pFillShapeEle, 0);

            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
示例#34
0
        public void DrawEnvelope(IEnvelope envelope)
        {
            if (envelope == null)
            {
                return;
            }
            try
            {
                //将鹰眼地图设置为地理容器,再设置为活动视图
                IGraphicsContainer pGraphicsContainer = this.axMapControl.Map as IGraphicsContainer;
                IActiveView        pActiveView        = pGraphicsContainer as IActiveView;
                //清除鹰眼地图中的任何图形元素
                pGraphicsContainer.DeleteAllElements();
                //设置矩形范围
                IRectangleElement pRectangeEle = new RectangleElementClass();
                IElement          pElement     = pRectangeEle as IElement;
                pElement.Geometry = envelope;

                //创建鹰眼图中的红线框
                IRgbColor pColor = new RgbColor();
                pColor.Red          = 255;
                pColor.Blue         = 0;
                pColor.Green        = 0;
                pColor.Transparency = 255;
                //创建线符号对象
                ILineSymbol pOutline = new SimpleLineSymbolClass();
                pOutline.Width = 2;
                pOutline.Color = pColor;

                //设置颜色属性
                pColor              = new RgbColorClass();
                pColor.Red          = 255;
                pColor.Blue         = 0;
                pColor.Green        = 0;
                pColor.Transparency = 0;

                //设置填充符号
                IFillSymbol pFillSymbol = new SimpleFillSymbolClass();
                pFillSymbol.Color   = pColor;
                pFillSymbol.Outline = pOutline;

                IFillShapeElement pFillShapeEle = pElement as IFillShapeElement;
                pFillShapeEle.Symbol = pFillSymbol;

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

                interEnvelope = envelope;
            }
            catch (Exception ex)
            {
                LoggingService.Error(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
示例#35
0
文件: Painter.cs 项目: nazzal88/ares
        /// <summary>
        /// Get the paint symble of painted pixel.
        /// </summary>
        /// <param name="filledColor">Fill color for the symbol</param>
        /// <returns></returns>
        public static ISimpleFillSymbol GetPaintSymbol(IColor filledColor)
        {
            ISimpleFillSymbol selectionSymbol = new SimpleFillSymbolClass();
            selectionSymbol.Color = filledColor;
            ISimpleLineSymbol selectionOutlineSymbol = new SimpleLineSymbolClass();
            selectionOutlineSymbol.Color = new RgbColorClass() { Red = 255, Green = 255, Blue = 0 };
            selectionOutlineSymbol.Width = 2;
            selectionSymbol.Outline = selectionOutlineSymbol;

            return selectionSymbol;
        }
示例#36
0
        /// <summary>
        /// 获取网格的边框样式
        /// </summary>
        /// <returns></returns>
        public static ISimpleMapGridBorder GetMapGridBorder()
        {
            //设置网格的边框样式
            ISimpleMapGridBorder simpleMapGridBorder = new SimpleMapGridBorderClass();
            ISimpleLineSymbol    simpleLineSymbol    = new SimpleLineSymbolClass();

            simpleLineSymbol.Style         = esriSimpleLineStyle.esriSLSSolid;
            simpleLineSymbol.Width         = 2;
            simpleMapGridBorder.LineSymbol = simpleLineSymbol;
            return(simpleMapGridBorder);
        }
示例#37
0
        private void MapGridBorderPropertyPage_Load(object sender, EventArgs e)
        {
            ILineSymbol symbol = new SimpleLineSymbolClass
            {
                Width = 1.0
            };

            this.btnOutlineSymbol.Style = symbol;
            this.Init();
            this.bool_0 = true;
        }
示例#38
0
        /// <summary>
        /// 简单线
        /// </summary>
        /// <param name="width"></param>
        /// <param name="color"></param>
        /// <param name="style"></param>
        /// <returns></returns>
        private ILineSymbol DefineLineSymbol(double width, IColor color, esriSimpleLineStyle style)
        {
            ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();

            simpleLineSymbol.Width = width;
            simpleLineSymbol.Color = color;
            simpleLineSymbol.Style = style;
            ILineSymbol lineSymbol = (ILineSymbol)simpleLineSymbol;

            return(lineSymbol);
        }
示例#39
0
        public void CopyMapToPageLayOutDataFrameforPrint(IMap MapControlOfMap)
        {
            this.m_OldMap = MapControlOfMap;
            IGraphicsContainerSelect graphicsContainer =
                this.axPageLayoutControl1.ActiveView.GraphicsContainer as IGraphicsContainerSelect;
            IElement  element = null;
            IMapFrame frame   = null;

            if (graphicsContainer.ElementSelectionCount <= 0)
            {
                this.CopyMapToPageLayOutforPrint(MapControlOfMap);
            }
            else
            {
                for (int i = 0; i < graphicsContainer.ElementSelectionCount; i++)
                {
                    element = graphicsContainer.SelectedElement(i);
                    if (element is IMapFrame)
                    {
                        frame = element as IMapFrame;
                        break;
                    }
                }
                if (frame != null)
                {
                    SimpleLineSymbolClass class2 = new SimpleLineSymbolClass();
                    IRgbColor             color  = new RgbColorClass
                    {
                        Red   = 255,
                        Green = 255,
                        Blue  = 255
                    };
                    class2.Color = color;
                    ISymbolBorder border = new SymbolBorderClass
                    {
                        LineSymbol = class2
                    };
                    frame.Border = border;
                    IObjectCopy copy      = new ObjectCopyClass();
                    object      pInObject = MapControlOfMap;
                    object      obj3      = copy.Copy(pInObject);
                    object      map       = frame.Map;
                    copy.Overwrite(obj3, ref map);
                    this.fullPageLayerOut(this.axPageLayoutControl1.ActiveView.FocusMap,
                                          (MapControlOfMap as IActiveView).Extent);
                    this.axPageLayoutControl1.ActiveView.Refresh();
                }
                else
                {
                    this.CopyMapToPageLayOutforPrint(MapControlOfMap);
                }
            }
        }
示例#40
0
 // Methods
 public static IFillSymbol CreateFillSymbol(Color fillColor, Color outlineColor)
 {
     SimpleFillSymbolClass class2 = new SimpleFillSymbolClass();
     class2.Style = esriSimpleFillStyle.esriSFSSolid;
     class2.Color = ColorHelper.CreateColor(fillColor);
     ISimpleLineSymbol symbol = new SimpleLineSymbolClass();
     symbol.Style = esriSimpleLineStyle.esriSLSSolid;
     symbol.Color = ColorHelper.CreateColor(outlineColor);
     symbol.Width = 1.0;
     class2.Outline = symbol;
     return class2;
 }
示例#41
0
 public static IFillSymbol CreateFillSymbol(Color fillColor, esriSimpleFillStyle eFillStyle, Color outlineColor, double outlineWidth, esriSimpleLineStyle outlineStyle)
 {
     SimpleFillSymbolClass class2 = new SimpleFillSymbolClass();
     class2.Style = eFillStyle;
     class2.Color = ColorHelper.CreateColor(fillColor);
     ISimpleLineSymbol symbol = new SimpleLineSymbolClass();
     symbol.Style = outlineStyle;
     symbol.Color = ColorHelper.CreateColor(outlineColor);
     symbol.Width = outlineWidth;
     class2.Outline = symbol;
     return class2;
 }
        public ProPortialRender(AxMapControl pMapcontrol, IFeatureLayer pFtLayer,  string pFieldName)
        {
            IGeoFeatureLayer pGeo = pFtLayer as IGeoFeatureLayer;

            IProportionalSymbolRenderer pProRender = new ProportionalSymbolRendererClass();

            pProRender.Field = pFieldName;

            pProRender.ValueUnit = esriUnits.esriUnknownUnits;

            ISimpleMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbolClass();

            pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;

            pMarkerSymbol.Size = 2;

            pMarkerSymbol.Color = GetRGBColor(255, 0, 0);

            pProRender.MinSymbol = pMarkerSymbol as ISymbol;

            IDataStatistics pDataStat = new DataStatisticsClass();

            IFeatureCursor pFtCursor = pFtLayer.FeatureClass.Search(null, false);

            pDataStat.Cursor = pFtCursor as ICursor;

            pDataStat.Field = pFieldName;

            pProRender.MinDataValue = pDataStat.Statistics.Minimum;

            pProRender.MaxDataValue = pDataStat.Statistics.Maximum;

            IFillSymbol pFillS = new SimpleFillSymbolClass();

            pFillS.Color = GetRGBColor(239, 228, 190);

            ILineSymbol pLineS = new SimpleLineSymbolClass();

            pLineS.Width = 2;

            pFillS.Outline = pLineS;

            ISimpleFillSymbol pSFillS = pFillS as ISimpleFillSymbol;

            pSFillS.Color = GetRGBColor(100, 100, 253);

            pProRender.BackgroundSymbol = pFillS;

            pGeo.Renderer = pProRender as IFeatureRenderer;

            pMapcontrol.ActiveView.Refresh();
        }
示例#43
0
        public static ISimpleLineSymbol CreateSimpleLineSymbol(IRgbColor rgbColor, System.Double inWidth, esriSimpleLineStyle inStyle)
        {
            if (rgbColor == null)
            {
                return null;
            }

            ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
            simpleLineSymbol.Style = inStyle;
            simpleLineSymbol.Color = rgbColor;
            simpleLineSymbol.Width = inWidth;

            return simpleLineSymbol;
        }
        public SimpleRender(AxMapControl pMapcontrol, IFeatureLayer pFtLayer, String Field)
        {
            IGeoFeatureLayer pGeolayer;

            IActiveView pActiveView;

            pGeolayer = pFtLayer as IGeoFeatureLayer;

            pActiveView = pMapcontrol.ActiveView;

            IFillSymbol pFillSymbol;

            ILineSymbol pLineSymbol;

            pFillSymbol = new SimpleFillSymbolClass();

            pFillSymbol.Color = GetRGBColor(220, 110, 200);

            pLineSymbol = new SimpleLineSymbolClass();

            pLineSymbol.Color = GetRGBColor(255, 120, 105);

            pLineSymbol.Width = 2;

            pFillSymbol.Outline = pLineSymbol;

            ISimpleRenderer pSimpleRender;//��ʲô������Ⱦ

            pSimpleRender = new SimpleRendererClass();

            pSimpleRender.Symbol = pFillSymbol as ISymbol ;

            pSimpleRender.Description = "China";

            pSimpleRender.Label = "SimpleRender";

            ITransparencyRenderer pTrans;

            pTrans = pSimpleRender as ITransparencyRenderer;

            pTrans.TransparencyField = Field;

            pGeolayer.Renderer = pTrans as IFeatureRenderer;

            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);

            //����ͼ�����Ⱦ������һ��Ҫ����Ⱦ���󣬶������������һЩ��ض�����ɵġ�
            //����Ҳ��һ������˵�����������С������ɵġ�
        }
示例#45
0
 public ClickSearchTool(string LayerName, string WhereClause, AxMapControl axMapControl,MainForm Father,bool Bus=false)
 {
     this.LayerName = LayerName;
     this.WhererClause = WhereClause;
     this.axMapControl = axMapControl;
     this.Father = Father;
     this.BusFlag = Bus;
     simpleLineSymbol = new SimpleLineSymbolClass();
     simpleLineSymbol.Width = 4;
     simpleLineSymbol.Color = DisplayHelper.GetRGBColor(255, 0, 99);
     simpleMarkerSymbol = new SimpleMarkerSymbolClass();
     simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
     simpleMarkerSymbol.Size = 8;
     simpleMarkerSymbol.Color = DisplayHelper.GetRGBColor(255, 0, 0);
 }
示例#46
0
        ///<summary>Draw a specified graphic on the map using the supplied colors.</summary>
        ///      
        ///<param name="map">An IMap interface.</param>
        ///<param name="geometry">An IGeometry interface. It can be of the geometry type: esriGeometryPoint, esriGeometryPolyline, or esriGeometryPolygon.</param>
        ///<param name="rgbColor">An IRgbColor interface. The color to draw the geometry.</param>
        ///<param name="outlineRgbColor">An IRgbColor interface. For those geometry's with an outline it will be this color.</param>
        ///      
        ///<remarks>Calling this function will not automatically make the graphics appear in the map area. Refresh the map area after after calling this function with Methods like IActiveView.Refresh or IActiveView.PartialRefresh.</remarks>
        public void AddGraphicToMap(IMap map, IGeometry geometry, IRgbColor rgbColor, IRgbColor outlineRgbColor)
        {
            IGraphicsContainer graphicsContainer = (IGraphicsContainer)map; // Explicit Cast
            IElement element = null;
            if ((geometry.GeometryType) == esriGeometryType.esriGeometryPoint)
            {
                // Marker symbols
                ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass();
                simpleMarkerSymbol.Color = rgbColor;
                simpleMarkerSymbol.Outline = true;
                simpleMarkerSymbol.OutlineColor = outlineRgbColor;
                simpleMarkerSymbol.Size = 15;
                simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;

                IMarkerElement markerElement = new MarkerElementClass();
                markerElement.Symbol = simpleMarkerSymbol;
                element = (IElement)markerElement; // Explicit Cast
            }
            else if ((geometry.GeometryType) == esriGeometryType.esriGeometryPolyline)
            {
                //  Line elements
                ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
                simpleLineSymbol.Color = rgbColor;
                simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
                simpleLineSymbol.Width = 5;

                ILineElement lineElement = new LineElementClass();
                lineElement.Symbol = simpleLineSymbol;
                element = (IElement)lineElement; // Explicit Cast
            }
            else if ((geometry.GeometryType) == esriGeometryType.esriGeometryPolygon)
            {
                // Polygon elements
                ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
                simpleFillSymbol.Color = rgbColor;
                simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSForwardDiagonal;
                IFillShapeElement fillShapeElement = new PolygonElementClass();
                fillShapeElement.Symbol = simpleFillSymbol;
                element = (IElement)fillShapeElement; // Explicit Cast
            }
            if (!(element == null))
            {
                element.Geometry = geometry;
                graphicsContainer.AddElement(element, 0);
            }
        }
示例#47
0
        public static ISimpleFillSymbol CreateSimpleFillSymbol(IRgbColor fillColor, esriSimpleFillStyle fillStyle, IRgbColor borderColor, esriSimpleLineStyle borderStyle, System.Double borderWidth)
        {
            if (fillColor == null || fillStyle == null || borderColor == null || borderStyle == null)
            {
                return null;
            }
            ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
            simpleLineSymbol.Width = borderWidth;
            simpleLineSymbol.Color = borderColor;
            simpleLineSymbol.Style = borderStyle;

            ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
            simpleFillSymbol.Outline = simpleLineSymbol;
            simpleFillSymbol.Style = fillStyle;
            simpleFillSymbol.Color = fillColor;

            return simpleFillSymbol;
        }
示例#48
0
 public Form1()
 {
     InitializeComponent();
     MXDPath = System.Configuration.ConfigurationManager.AppSettings["MXD"];
     RoadName = System.Configuration.ConfigurationManager.AppSettings["ROAD"];
     BusLineName = System.Configuration.ConfigurationManager.AppSettings["BUSLINE"];
     BusStopName = System.Configuration.ConfigurationManager.AppSettings["BUSSTOP"];
     ParkingName = System.Configuration.ConfigurationManager.AppSettings["PARKING"];
     BikeName = System.Configuration.ConfigurationManager.AppSettings["BIKE"];
     FlowName = System.Configuration.ConfigurationManager.AppSettings["FLOW"];
     simpleLineSymbol = new SimpleLineSymbolClass();
     simpleLineSymbol.Width = 4;
     simpleLineSymbol.Color = DisplayHelper.GetRGBColor(255, 0, 99);
     simpleMarkerSymbol = new SimpleMarkerSymbolClass();
     simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
     simpleMarkerSymbol.Size = 8;
     simpleMarkerSymbol.Color = DisplayHelper.GetRGBColor(255, 0, 0);
 }
示例#49
0
        public MainForm()
        {
            InitializeComponent();
            MapControl = RendererHelper.GetMapControl();
            MXDPath = ConfigurationManager.AppSettings["MXD"];
            RoadName = ConfigurationManager.AppSettings["ROAD"];
            RoadHistoryName = ConfigurationManager.AppSettings["ROADHISTORY"];
            RoadNodeName = ConfigurationManager.AppSettings["ROADNODE"];
            BusLineName = ConfigurationManager.AppSettings["BUSLINE"];
            BusStopName = ConfigurationManager.AppSettings["BUSSTOP"];
            ParkingName = ConfigurationManager.AppSettings["PARKING"];
            BikeName = ConfigurationManager.AppSettings["BIKE"];
            FlowName = ConfigurationManager.AppSettings["FLOW"];
            StartEndName = ConfigurationManager.AppSettings["BUSSTOPNAME"];
            XZQName = ConfigurationManager.AppSettings["XZQ"];
            MapType = ConfigurationManager.AppSettings["MAPTYPE"];

            simpleLineSymbol = new SimpleLineSymbolClass();
            simpleLineSymbol.Width = 4;
            simpleLineSymbol.Color = DisplayHelper.GetRGBColor(255, 0, 99);
            simpleMarkerSymbol = new SimpleMarkerSymbolClass();
            simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
            simpleMarkerSymbol.Size = 8;
            simpleMarkerSymbol.Color = DisplayHelper.GetRGBColor(255, 0, 0);

            m_CrossroadSymbol = new SimpleMarkerSymbolClass()
            {
                Style = esriSimpleMarkerStyle.esriSMSCircle,
                Size = 8,
                Color = DisplayHelper.GetRGBColor(255, 0, 0, 0),
                OutlineColor = DisplayHelper.GetRGBColor(255, 0, 0),
                OutlineSize = 3,
                Outline = true
            };

            m_ImportRoadSymbol = new SimpleLineSymbolClass()
            {
                Style = esriSimpleLineStyle.esriSLSSolid,
                Width = 3,
                Color = DisplayHelper.GetRGBColor(0, 0, 0, 200)
            };
            axMapControl1.OnAfterDraw += this.axMapControl1_OnAfterDraw;
        }
        private IElement GetElement(IGeometry geometry, double width, esriSimpleLineStyle simpleLineStyle)
        {
            IElement element;

            ILineElement lineElement = new LineElementClass();
            element = lineElement as IElement;

            ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
            simpleLineSymbol.Style = simpleLineStyle;
            simpleLineSymbol.Color = ColorSelection.GetColor();
            simpleLineSymbol.Width = width;

            element.Geometry = geometry;

            ILineSymbol lineSymbol = simpleLineSymbol as ILineSymbol;

            lineElement.Symbol = lineSymbol;

            return element;
        }
示例#51
0
文件: MapForm.cs 项目: gistop/aegis
 private void axMapControl1_OnExtentUpdated(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnExtentUpdatedEvent e)
 {
     //得到新范围
     IEnvelope pEnvelop = (IEnvelope)e.newEnvelope;
     IGraphicsContainer pGraphicsContainer = Global.eagleeye.Map as IGraphicsContainer;
     IActiveView pActiveView = pGraphicsContainer as IActiveView;
     //在绘制前。清除axMapControl2 中的任何图形元素
     pGraphicsContainer.DeleteAllElements();
     IRectangleElement pRectangleEle = new RectangleElementClass();
     IElement pElement = pRectangleEle as IElement;
     pElement.Geometry = pEnvelop;
     //设置鹰眼中的红线框
     IRgbColor pColor = new RgbColorClass();
     pColor.Red = 255;
     pColor.Green = 0;
     pColor.Blue = 0;
     pColor.Transparency = 255;
     //产生一个线符号对象
     ILineSymbol pOutline = new SimpleLineSymbolClass();
     pOutline.Width = 1;
     pOutline.Color = pColor;
     //设置颜色属性
     pColor = new RgbColorClass();
     pColor.Red = 255;
     pColor.Green = 0;
     pColor.Blue = 0;
     pColor.Transparency = 0;
     //设置填充符号的属性
     IFillSymbol pFillSymbol = new SimpleFillSymbolClass();
     pFillSymbol.Color = pColor;
     pFillSymbol.Outline = pOutline;
     IFillShapeElement pFillShapeEle = pElement as IFillShapeElement;
     pFillShapeEle.Symbol = pFillSymbol;
     pGraphicsContainer.AddElement((IElement)pFillShapeEle, 0);
     pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
 }
示例#52
0
 private void CreateOverviewSymbol()
 {
     IRgbColor iRgb = new RgbColorClass();
     iRgb.RGB = 255;
     ILineSymbol pOutline = new SimpleLineSymbolClass();
     pOutline.Color = iRgb;
     pOutline.Width = 2.3;
     ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass();
     pSimpleFillSymbol.Outline = pOutline;
     pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSHollow;
     oFillobject = pSimpleFillSymbol;
 }
示例#53
0
        public static void FlashPolyline(IScreenDisplay pDisplay, IGeometry pGeometry)
        {
            ISimpleLineSymbol pLineSymbol = new SimpleLineSymbolClass();
            pLineSymbol.Width = 4;
            IRgbColor pRgbColor = new RgbColorClass();
            pRgbColor.Green = 100;
            pRgbColor.Red = 150;
            pRgbColor.Blue = 100;
            pLineSymbol.Color = pRgbColor as IColor;
            ISymbol pSymbol = pLineSymbol as ISymbol;
            pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;

            pDisplay.SetSymbol(pSymbol);
            pDisplay.DrawPolyline(pGeometry);

            Thread.Sleep(300);
            pDisplay.DrawPolyline(pGeometry);
        }
示例#54
0
        private ISpatialFilter GenerateSpatialFilter()
        {
            frmPromptQuerying frmPrompt = new frmPromptQuerying(4);//��ʾ����������ͼ���� Ϊ�����쳣ʱ�ܽ�����ʾ���ڹرգ����Է���try����
            try
            {
                frmPrompt.Show();
                System.Windows.Forms.Application.DoEvents();//'ת�ÿ���Ȩ��û����һ��Ļ���ʾ���ڲ���������ʾ
                //����Ҫ�����spatialfilter
                //��ù���spatialfilter.geometry������feature
                //IMap pMap;                        //����QI��IEnumLayer
                //IEnumLayer pEnumLayer;            //����������Ϊ��ѡ���layers
                //ILayer pLayer;
                IFeatureLayer pFeatureLayer = null;
                IGeometry pGeometry = null;
                IEnumFeature pEnumFeature = null;          //�����зֱ�����ʹ�úͲ�ʹ��
                IFeatureCursor pFeatureCursor = null;      //�Ѿ�ѡ���Ԫ�����ɡ�ɸѡͼ�Ρ������
                IFeatureClass pFeatureClass;
                IFeature pFeature;
                string strLayerName = comboBoxConditionLayer.Text;
                if (checkBoxUseSelectedOnly.Checked == false)    //����û��Լ�ѡ������ͼ�㡱,��������ѡ�е�Ԫ��
                {
                    pFeatureLayer = GetLayerbyName(strLayerName) as IFeatureLayer;  //���layer����������spatialfilter.geometry��
                    //���Ǹ�������ͼ�㡱

                    //���ﲻ��featureselection�����enumfeature,�Ӷ����������geometry�ϲ�������ȡfeaturecursor������Ϊ
                    //��featureselection�Ļ�����ô��ϲ�������feature��һ�������ôд��featureselection=mainaxmapcontrol.map.featureselection
                    //������ָ��featureselection��map�����һ���㣡���������featureselection=pfeaturelayer.featureselection��
                    //Ȼ��enumfeature=featureselection����ʱenumfeature����null�����е�pfeaturelayer�Ѿ���map���һ��ָ���IJ��ˣ�
                    //�����featureselection=mainaxmapcontrol.map.featureselection���ͻ������⣺Ҳ��map�����Ѿ��б�ѡ�е�Ԫ���ˣ�����ʱ�����ַ���
                    //��õ�enumfeatureֻ������Щ�Ѿ�ѡ�е�Ԫ�أ�����Ӧ����������Ӧ�û�õ���ָ��Ϊ������ͼ�㡱������feature������ֻ����featurecursor
                    //�����featureselection�Ļ���Ҫ��ôд��
                    //IFeatureSelection pFeatureSelection = MainaxMapControl.get_Layer(strLayerName) as IFeatureSelection;
                    //pFeatureSelection.SelectFeatures(null, esriSelectionResultEnum.esriSelectionResultNew, false);//��ʹ���ѱ�ѡ�е�Ԫ��ʱ������仰Խ��ȥ
                    //IEnumFeature pEnumFeature = MainaxMapControl.Map.FeatureSelection as IEnumFeature;
                    pFeatureClass = pFeatureLayer.FeatureClass;
                    pFeatureCursor = pFeatureClass.Search(null, true);
                    pFeature = pFeatureCursor.NextFeature();
                }
                else            //���ʹ�õ�ͼ����ѡ�е�Ԫ����Ϊ��ɸѡͼ�㡱
                {
                    pEnumFeature = MainAxMapControl.Map.FeatureSelection as IEnumFeature;
                    pFeature = pEnumFeature.Next();
                }

                pGeometry = pFeature.Shape;
                ITopologicalOperator pTopologicalOperator;
                //�ϲ������Ե���ɸ�ӡ���geometry
                while (pFeature != null)
                {

                    //�����һ���ǹؼ����������յ�pgeometry���Ի���������geometry
                    //��ΪTopologicalOperator�������һ��shape��һ��geometry�����Խ����������������ĺϲ�.
                    //ֻ����shapecopy���ܹ���ȷ����shape�Ļ����ļ��ͳ����Ϊ��������ⵢ����һ���ڣ�����
                    //����һ��˼·Ҳ���ԡ������˼·����ѭ���ϲ�����geometry����һ��˼·����ѭ���õ�����ÿ��
                    //geometryȥɸѡͼ�����featuresȻ��ϲ����
                    pTopologicalOperator = pFeature.ShapeCopy as ITopologicalOperator;
                    //if (checkBoxBuffer.Checked == true)
                    //{
                    //    double ddistance = Convert.ToDouble(textBoxBuffer.Text);
                    //    pGeometry = pTopologicalOperator.Buffer(ddistance);
                    //    //pTopologicalOperator.Simplify();        //ʹ���˹�ϵ�����ȷ
                    //}
                    pGeometry = pTopologicalOperator.Union(pGeometry as IGeometry);
                    if (checkBoxUseSelectedOnly.Checked == false)//�õ���featurecursor
                        pFeature = pFeatureCursor.NextFeature();
                    else pFeature = pEnumFeature.Next();
                }
                //pFeatureSelection.Clear();//������������������geometry��������featureselection�Ļ�����Ҳ��һ��ؼ���
                //�������յ���ʾҲ�������featureselection��ʾ����

                //���ɻ����������������ѭ��֮��ִ�У������Ӹ���Ч�ʣ����Ҹ������׳���
                if (checkBoxBuffer.Checked == true)
                {
                    double ddistance = Convert.ToDouble(textBoxBuffer.Text);
                    pTopologicalOperator = pGeometry as ITopologicalOperator;
                    pGeometry = pTopologicalOperator.Buffer(ddistance);
                    pTopologicalOperator.Simplify();        //ʹ���˹�ϵ�����ȷ
                    //MainAxMapControl.FlashShape(pGeometry, 2, 500, null);//��˸����֤��������ȷ���
                }
                frmPrompt.WindowState = FormWindowState.Minimized;
                frmPrompt.Dispose();
                System.Windows.Forms.Application.DoEvents();
                object m_fillsymbol;                                //�����drawshape�IJ���������object��

                IRgbColor pRgb = new RgbColorClass();               // ��ȡIRGBColor�ӿ�
                pRgb.Red = 255;                                     // ������ɫ����
                ILineSymbol outline = new SimpleLineSymbolClass();          // ��ȡILine���Žӿ�
                outline.Width = 5;
                outline.Color = pRgb;
                ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();// ��ȡIFillSymbol�ӿ�
                simpleFillSymbol.Outline = outline;
                simpleFillSymbol.Color = pRgb;
                simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSBackwardDiagonal;
                m_fillsymbol = simpleFillSymbol;
                //MainAxMapControl.DrawShape(pGeometry, ref m_fillsymbol);
                MainAxMapControl.FlashShape(pGeometry, 3, 500, m_fillsymbol);//��˸�����û�֪����ǰ��"����ͼ��"����״

                ISpatialFilter pSpatialFilter = new SpatialFilterClass();
                pSpatialFilter.Geometry = pGeometry;
                pSpatialFilter.SpatialRel = pSpatialRel;        //���Ǹ�ȫ�ֱ���
                if (checkBoxUseSelectedOnly.Checked == true)
                    pSpatialFilter.GeometryField = "Shape";     //��ʹ����ѡ�е�Ԫ����Ϊ��ɸѡͼ�㡱ʱ��
                //�޷����������ȥ���geometryfield����Ϊpfeaturelayer(����ͼ��)Ϊ��
                else
                    pSpatialFilter.GeometryField = pFeatureLayer.FeatureClass.ShapeFieldName;

                return pSpatialFilter;
            }
            catch (Exception ex)
            {
                MessageBox.Show("���ɡ�����ͼ�㡱����!���� | " + ex.Message);
                frmPrompt.Dispose();
                return null;//�����򲻷���spatialfitler
            }
        }
示例#55
0
        private void convertColorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IColor pColor = GetRGB(Color.Black);
            if (colorDlg.ShowDialog() == DialogResult.OK)
            {
                pColor = GetRGB(colorDlg.Color);
            }

            IMap mmap = axMapControl1.Map;
            IActiveView pActiveView = mmap as IActiveView;

            IGeometry pLine = axMapControl1.TrackLine();

            ISimpleLineSymbol pLineSymbol = new SimpleLineSymbolClass();
            pLineSymbol.Color = pColor;
            pLineSymbol.Width = 2;
            pLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;

            IElement element = new LineElementClass();
            element.Geometry = pLine;
            ILineElement pLineElement = element as ILineElement;
            pLineElement.Symbol = pLineSymbol;

            IGraphicsContainer ppGraphicsContainer = mmap as IGraphicsContainer;
            ppGraphicsContainer.AddElement(pLineElement as IElement, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
        /// <summary>
        /// draw footprints on the map
        /// </summary>
        /// <param name="record">Record for which the footprint needs to be drwan</param>
        /// <param name="refreshview">Indicates if the view is refreshed or not after the element is drawn</param>
        /// <param name="deleteelements">Indicates if the element can be deleted or not</param>
        private void drawfootprint(CswRecord record, bool refreshview, bool deleteelements)
        {
            //create the triangle outline symbol
            ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass();
            lineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
            lineSymbol.Width = 2.0;

            //create the triangle's fill symbol
             ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
            simpleFillSymbol.Outline = (ILineSymbol)lineSymbol;
            simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSDiagonalCross;

            IMxDocument mxDoc;
            mxDoc = (IMxDocument)m_application.Document;

            //the original projection system
            ISpatialReference spatialReference;
            IGeographicCoordinateSystem geographicCoordinateSystem;
            SpatialReferenceEnvironmentClass spatialReferenceEnviorment = new SpatialReferenceEnvironmentClass();
            geographicCoordinateSystem = spatialReferenceEnviorment.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);
            spatialReference = (ISpatialReference)geographicCoordinateSystem;

            //set the geometry of the element
            IPoint point = new ESRI.ArcGIS.Geometry.PointClass();
            point.SpatialReference = spatialReference;
            point.PutCoords(record.BoundingBox.Minx, record.BoundingBox.Miny);

            IPoint point1 = new ESRI.ArcGIS.Geometry.PointClass();
            point1.SpatialReference = spatialReference;
            point1.PutCoords(record.BoundingBox.Minx, record.BoundingBox.Maxy);

            IPoint point2 = new ESRI.ArcGIS.Geometry.PointClass();
            point2.SpatialReference = spatialReference;
            point2.PutCoords(record.BoundingBox.Maxx, record.BoundingBox.Maxy);

            IPoint point3 = new ESRI.ArcGIS.Geometry.PointClass();

               point3.SpatialReference = spatialReference;
               point3.PutCoords(record.BoundingBox.Maxx, record.BoundingBox.Miny);

            IPointCollection pointCollection;
            pointCollection = new ESRI.ArcGIS.Geometry.PolygonClass();

            object x = Type.Missing;
            object y = Type.Missing;

            pointCollection.AddPoint(point, ref x, ref y);
            pointCollection.AddPoint(point1, ref x, ref y);
            pointCollection.AddPoint(point2, ref x, ref y);
            pointCollection.AddPoint(point3, ref x, ref y);

            PolygonElementClass element = new PolygonElementClass();
            element.Symbol = simpleFillSymbol;
            element.SpatialReference = spatialReference;
            element.Geometry.SpatialReference = spatialReference;
            element.Geometry = (IGeometry)pointCollection;
            element.Geometry.Project(mxDoc.ActiveView.Extent.SpatialReference);

            //add the graphics element to the map
            IGraphicsContainer graphicsContainer;
            graphicsContainer = (IGraphicsContainer)mxDoc.FocusMap;
            if (deleteelements) {
                graphicsContainer.DeleteAllElements();
            }
            graphicsContainer.AddElement(element, 0);
            if (refreshview) {
                mxDoc.ActiveView.Extent = element.Geometry.Envelope;
                mxDoc.ActiveView.Refresh();
            }
        }
示例#57
0
 /// <summary>
 /// 简单线
 /// </summary>
 /// <param name="width"></param>
 /// <param name="color"></param>
 /// <param name="style"></param>
 /// <returns></returns>
 private ILineSymbol DefineLineSymbol(double width, IColor color, esriSimpleLineStyle style)
 {
     ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
     simpleLineSymbol.Width = width;
     simpleLineSymbol.Color = color;
     simpleLineSymbol.Style = style;
     ILineSymbol lineSymbol = (ILineSymbol)simpleLineSymbol;
     return lineSymbol;
 }
示例#58
0
        private ILineSymbol DefineLineOutLineSymbol()
        {
            ISimpleLineSymbol backBlackLine = new SimpleLineSymbolClass();
            backBlackLine.Width = 5.5;
            backBlackLine.Color = DefineRgbColor(0, 0, 0);
            backBlackLine.Style = esriSimpleLineStyle.esriSLSSolid;

            ISimpleLineSymbol foreGreenLine = new SimpleLineSymbolClass();
            foreGreenLine.Width = 4;
            foreGreenLine.Color = DefineRgbColor(0, 128, 0);
            foreGreenLine.Style = esriSimpleLineStyle.esriSLSSolid;

            IMultiLayerLineSymbol multiLayerLineSymbol = new MultiLayerLineSymbolClass();
            multiLayerLineSymbol.AddLayer(backBlackLine);
            multiLayerLineSymbol.AddLayer(foreGreenLine);
            ILineSymbol lineSymbol = (ILineSymbol)multiLayerLineSymbol;

            return lineSymbol;
        }
示例#59
0
文件: 1.cs 项目: trainsn/LBS
        public override void RefreshFeedBack()
        {
            try
            {
                if (TheReferenceInstances.TheAEditer.SketchEdit.DrawGeometry == null)
                    return;

                //屏幕绘制graphic表达此刻的Geometry
                IElement ipElement = null;
                if(_subType == 1)
                {
                    ipElement = new LineElementClass();
                    ipElement.Geometry = TheReferenceInstances.TheAEditer.SketchEdit.DrawGeometry;
                }
                else if(_subType == 2)
                {
                    ipElement = new PolygonElementClass();
                    ipElement.Geometry = TheReferenceInstances.TheAEditer.SketchEdit.DrawGeometry;
                    ipElement.Geometry.SpatialReference = TheReferenceInstances.TheAEditer.SketchEdit.DrawGeometry.SpatialReference;

                    //绘制Geometry时使用空心红框,以方便查看叠盖关系
                    ISimpleFillSymbol iSymbol = new SimpleFillSymbolClass();
                    ISimpleLineSymbol iOutlineSymbol = new SimpleLineSymbolClass();
                    IColor irgbColor = new RgbColorClass();
                    (irgbColor as IRgbColor).Red = 255; (irgbColor as IRgbColor).Blue = 0; (irgbColor as IRgbColor).Green = 0;
                    iOutlineSymbol.Color = irgbColor;
                    iSymbol.Style = esriSimpleFillStyle.esriSFSHollow;
                    iSymbol.Outline = iOutlineSymbol;
                    (ipElement as IFillShapeElement).Symbol = iSymbol;

                }

                (myHook.FocusMap as IGraphicsContainer).AddElement(ipElement, 0);
                (myHook.FocusMap as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGraphics, ipElement, TheReferenceInstances.TheAEditer.SketchEdit.DrawGeometry.Envelope);
                InfoUserStatusbar.InfoTip = "草图绘制完成!";
            }
            catch (System.Exception e)
            {
                throw new ApplicationException(String.Format("把草图更新到Map出错!\n{0}", e.Message));
                InfoUserStatusbar.InfoTip = "草图绘制失败!";
            }
            finally
            {
                if (myHook.Hook is IMapControl3)
                {
                    TheReferenceInstances.TheAxMapControl.MousePointer = esriControlsMousePointer.esriPointerDefault;
                    (myHook.Hook as IMapControl3).CurrentTool = null;
                }
                else if (myHook.Hook is IPageLayoutControl2)
                {
                    (myHook.Hook as IPageLayoutControl2).CurrentTool = null;
                }

                m_cursor = Cursors.Default;
            }
        }
    private IUniqueValueRenderer CreateTrackUniqueValueRenderer(IFeatureClass featureClass, string fieldName)
    {
      IRgbColor color = new RgbColorClass();
      color.Red = 0;
      color.Blue = 0;
      color.Green = 255;

      ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
      simpleLineSymbol.Color = (IColor)color;
      simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
      simpleLineSymbol.Width = 1.0;

      IUniqueValueRenderer uniqueRenderer = new UniqueValueRendererClass();
      uniqueRenderer.FieldCount = 1;
      uniqueRenderer.set_Field(0, fieldName);
      uniqueRenderer.DefaultSymbol = (ISymbol)simpleLineSymbol;
      uniqueRenderer.UseDefaultSymbol = true;

      Random rand = new Random();
      bool bValFound = false;
      IFeatureCursor featureCursor = featureClass.Search(null, true);
      IFeature feature = null;
      string val = string.Empty;
      int fieldID = featureClass.FindField(fieldName);
      if (-1 == fieldID)
        return uniqueRenderer;

      while ((feature = featureCursor.NextFeature()) != null)
      {
        bValFound = false;
        val = Convert.ToString(feature.get_Value(fieldID));
        for (int i = 0; i < uniqueRenderer.ValueCount - 1; i++)
        {
          if (uniqueRenderer.get_Value(i) == val)
            bValFound = true;
        }

        if (!bValFound)//need to add the value to the renderer
        {
          color.Red = rand.Next(255);
          color.Blue = rand.Next(255);
          color.Green = rand.Next(255);

          simpleLineSymbol = new SimpleLineSymbolClass();
          simpleLineSymbol.Color = (IColor)color;
          simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
          simpleLineSymbol.Width = 1.0;

          //add the value to the renderer
          uniqueRenderer.AddValue(val, "name", (ISymbol)simpleLineSymbol);
        }
      }

      //release the featurecursor
      ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(featureCursor);

      return uniqueRenderer;
    }