Пример #1
0
        private void btnApply_Click(object sender, EventArgs e)
        {
            clsSnippet     pSnippet        = new clsSnippet();
            FormCollection pFormCollection = System.Windows.Forms.Application.OpenForms;
            frmSymbology   pfrmSymbology   = null;

            for (int j = 0; j < pFormCollection.Count; j++)
            {
                if (pFormCollection[j].Name == "frmSymbology")//Brushing to Histogram
                {
                    pfrmSymbology = pFormCollection[j] as frmSymbology;
                }
            }

            ISimpleFillSymbol pBackFillSymbol = null;

            if (pfrmSymbology != null)
            {
                pBackFillSymbol = new SimpleFillSymbolClass();
                IRgbColor pBackRGB = new RgbColorClass();
                pBackRGB = pSnippet.getRGB(picSymColor.BackColor.R, picSymColor.BackColor.G, picSymColor.BackColor.B);
                pBackFillSymbol.Color = (IColor)pBackRGB;
                ICartographicLineSymbol pBackOut = new CartographicLineSymbolClass();
                IRgbColor pBackOutRGB            = new RgbColorClass();
                pBackOutRGB                = pSnippet.getRGB(picOutColor.BackColor.R, picOutColor.BackColor.G, picOutColor.BackColor.B);
                pBackOut.Color             = (IColor)pBackOutRGB;
                pBackOut.Width             = Convert.ToDouble(nudOutWidth.Value);
                pBackFillSymbol.Outline    = pBackOut;
                pfrmSymbology.m_BackSymbol = pBackFillSymbol;
            }
            this.Close();
        }
Пример #2
0
        private void BreakClassRender()
        {
            IGeoFeatureLayer geoFeatureLayer;

            geoFeatureLayer = getGeoLayer("Continents");
            IUniqueValueRenderer uniqueValueRenderer = new UniqueValueRendererClass();

            uniqueValueRenderer.FieldCount = 1;
            uniqueValueRenderer.set_Field(0, "SQMI");
            ISimpleFillSymbol simpleFillSymbol = SymbolWorker.CreateSimpleFillSymbol() as ISimpleFillSymbol;
            IFeatureCursor    featureCursor    = geoFeatureLayer.FeatureClass.Search(null, false);
            IFeature          feature;

            if (featureCursor != null)
            {
                IEnumColors enumColors = SymbolWorker.CreateAlgorithmicColorRamp(7).Colors;
                int         fiedIndex  = geoFeatureLayer.FeatureClass.Fields.FindField("SQMI");
                for (int i = 0; i < 7; i++)
                {
                    feature = featureCursor.NextFeature();
                    string nameValue = feature.get_Value(fiedIndex).ToString();
                    simpleFillSymbol       = new SimpleFillSymbolClass();
                    simpleFillSymbol.Color = enumColors.Next();
                    uniqueValueRenderer.AddValue(nameValue, "SQMI", simpleFillSymbol as ISymbol);
                }
            }
            geoFeatureLayer.Renderer = uniqueValueRenderer as IFeatureRenderer;
        }
Пример #3
0
        public static IElement CreatePolygonElement(IActiveView pActiveView, IGeometry pGeo)
        {
            Random    rnd   = new Random();
            IRgbColor color = new RgbColorClass();

            color.Blue  = rnd.Next(0, 255);
            color.Green = rnd.Next(0, 255);
            color.Red   = rnd.Next(0, 255);
            IColor            color2 = color;
            ISimpleLineSymbol symbol = new SimpleLineSymbolClass();

            symbol.Style = esriSimpleLineStyle.esriSLSSolid;
            symbol.Color = color2;
            symbol.Width = 2.0;
            ISimpleFillSymbol symbol2 = new SimpleFillSymbolClass();

            symbol2.Style = esriSimpleFillStyle.esriSFSBackwardDiagonal;
            IRgbColor color3 = new RgbColorClass();

            color.Blue      = rnd.Next(0, 255);
            color.Green     = rnd.Next(0, 255);
            color.Red       = rnd.Next(0, 255);
            symbol2.Color   = color3;
            symbol2.Outline = symbol;
            pGeo            = ErrManager.ConvertPoject(pGeo, pActiveView.FocusMap.SpatialReference);
            ISimpleFillSymbol symbol3 = symbol2;
            IElement          element = new PolygonElementClass();

            element.Geometry = pGeo;
            IFillShapeElement element2 = element as IFillShapeElement;

            element2.Symbol = symbol3;
            return(element);
        }
Пример #4
0
        /// <summary>
        /// Resets the default configuration.
        /// </summary>
        public static void SetDefault()
        {
            selectionSymbol       = new SimpleFillSymbolClass();
            selectionSymbol.Color = new RgbColorClass()
            {
                NullColor = true, Transparency = 0
            };
            ISimpleLineSymbol selectionOutlineSymbol = new SimpleLineSymbolClass();

            selectionOutlineSymbol.Color = new RgbColorClass()
            {
                Red = 0, Green = 255, Blue = 255
            };
            selectionOutlineSymbol.Width = 2;
            selectionSymbol.Outline      = selectionOutlineSymbol;

            customEditRender = false;
            editSymbol       = new SimpleFillSymbolClass();
            editSymbol.Color = new RgbColorClass()
            {
                Red = 255, Green = 255, Blue = 90, Transparency = 127
            };
            ISimpleLineSymbol editOutlineSymbol = new SimpleLineSymbolClass();

            editOutlineSymbol.Color = new RgbColorClass()
            {
                Red = 255, Green = 255, Blue = 0
            };
            editOutlineSymbol.Width = 2;
            editSymbol.Style        = esriSimpleFillStyle.esriSFSBackwardDiagonal;
            editSymbol.Outline      = editOutlineSymbol;
        }
Пример #5
0
        /// <summary>
        ///     Adds a black rectangle in the lower right corner area just below the mapframe. The white
        ///     text CITY OF MEDFORD is added on top of this rectangle.
        /// </summary>
        public override void addMedfordRectangle()
        {
            CSpatialSubs       oSpatialSubs = new CSpatialSubs();
            IMxDocument        pMxDoc       = (IMxDocument)ArcMap.Document;
            IGraphicsContainer pGC          = (IGraphicsContainer)pMxDoc.PageLayout;

            try
            {
                ILineSymbol       pLineSym    = oSpatialSubs.createSimpleLineSymbol(oSpatialSubs.createRGB(0, 0, 0), base.XFactor, esriSimpleLineStyle.esriSLSSolid);
                ISimpleFillSymbol pFillSymbol = (ISimpleFillSymbol)oSpatialSubs.createSimpleFillSymbol(oSpatialSubs.createRGB(0, 0, 0), pLineSym, esriSimpleFillStyle.esriSFSSolid);

                oSpatialSubs.addRectangleToGraphicsContainer(pGC,
                                                             (IFillSymbol)pFillSymbol,
                                                             (base.XFactor * SPrintConst.MapFrame_XMax),
                                                             (base.XFactor * SPrintConst.Neatline_XMax),
                                                             (base.YFactor * (SPrintConst.Neatline_YMax - SPrintConst.Logo_Offset)),
                                                             (base.YFactor * SPrintConst.Neatline_YMax));
                pLineSym    = null;
                pFillSymbol = null;
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("Errors: CLandscapeLayout:addMedfordRectangle()\r\n" + ex.Message, "Errors occurred", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
            finally
            {
                oSpatialSubs.Dispose();
                pMxDoc = null;
                pGC    = null;
            }
        }
Пример #6
0
        /// <summary>
        /// 高亮显示多边形
        /// </summary>
        /// <param name="pDisplay">用于操作的显示屏幕</param>
        /// <param name="pGeometry">欲高亮显示的几何图形</param>
        private void FlashPolygon(IScreenDisplay pDisplay, IGeometry pGeometry)
        {
            if (pGeometry == null)
            {
                return;
            }

            //设置显示格式
            ISimpleFillSymbol pFillSymbol = null;

            pFillSymbol         = new SimpleFillSymbol();
            pFillSymbol.Outline = null;
            pFillSymbol.Color   = GetRGBColor(255, 150, 150);

            ISymbol pSymbol = default(ISymbol);

            pSymbol      = pFillSymbol as ISymbol;
            pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;

            //用所设置的格式绘制几何图形
            pDisplay.SetSymbol((ISymbol)pFillSymbol);
            pDisplay.DrawPolygon(pGeometry);
            Thread.Sleep(100);
            pDisplay.DrawPolygon(pGeometry);
        }
Пример #7
0
        /// <summary>
        /// 单击颜色单元格选颜色
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SC_dataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == SC_dataGridView.Columns["color"].Index && e.RowIndex != -1)
            {
                SC_dataGridView.ClearSelection();

                ColorDialog cd = new ColorDialog();
                if (cd.ShowDialog() == DialogResult.OK)
                {
                    SC_dataGridView.Rows[e.RowIndex].Cells["color"].Style.BackColor = cd.Color;

                    //根据选中颜色新建绘制图形的填充符号
                    IRgbColor arccolor = new RgbColorClass();
                    arccolor.RGB = cd.Color.B * 65536 + cd.Color.G * 256 + cd.Color.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 = SC_dataGridView.Rows[e.RowIndex].Cells["color"].Tag as IGeometry;

                    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);
                }
            }
        }
Пример #8
0
        private void MainMap_OnAfterDraw(object sender, IMapControlEvents2_OnAfterDrawEvent e)
        {
            // 绘制红色鹰眼框
            object           pSym = null;
            SimpleLineSymbol pOutlineSym;
            IRgbColor        pColor;

            pColor       = new RgbColorClass();
            pColor.Red   = 255;
            pColor.Blue  = 0;
            pColor.Green = 0;
            pSym         = new SimpleFillSymbolClass();
            ISimpleFillSymbol pSym1 = pSym as ISimpleFillSymbol;

            pSym1.Style = esriSimpleFillStyle.esriSFSHollow;

            pOutlineSym       = new SimpleLineSymbolClass();
            pOutlineSym.Width = 1;
            pOutlineSym.Style = esriSimpleLineStyle.esriSLSSolid;
            pOutlineSym.Color = pColor;
            pSym1.Outline     = pOutlineSym;

            if (m_pEnvelope == null)
            {
                return;
            }
            MapViewer.DrawShape(m_pEnvelope as IGeometry, ref pSym);
        }
Пример #9
0
        public void Load(IVariantStream Stream)
        {
            int ver = (int)Stream.Read();

            if (ver > c_Version || ver <= 0)
            {
                throw new Exception("Wrong version!");
            }

            InitMembers();

            m_size            = (double)Stream.Read();
            m_scaleRef        = (double)Stream.Read();
            m_anchorPointType = (esriAnchorPointEnum)Stream.Read();
            m_autoTrans       = (bool)Stream.Read();
            m_elementType     = (string)Stream.Read();
            m_elementName     = (string)Stream.Read();
            m_nativeSR        = Stream.Read() as ISpatialReference;
            m_fillSymbol      = Stream.Read() as ISimpleFillSymbol;
            m_pointGeometry   = Stream.Read() as IPoint;
            m_triangle        = Stream.Read() as IPolygon;

            if (ver == 2)
            {
                m_rotation = (double)Stream.Read();
            }
        }
Пример #10
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="_graphicsLayer">图层</param>
        /// <parparam name="polygonKml">面的kml</parparam>
        public Polygon_ArcGlobe(IGlobeGraphicsLayer _graphicsLayer, KmlPolygon polygonKml)
        {
            this.graphicsLayer = _graphicsLayer;

            this.ElementType = ElementTypeEnum.Polygon;           //图元类型
            this.Description = polygonKml.Description;            //图元描述

            #region  符号

            simpleFillSymbol = new SimpleFillSymbolClass();
            simpleLineSymbol = new SimpleLineSymbolClass();

            IRgbColor fillColor = new RgbColorClass();
            fillColor.Transparency = polygonKml.FillColor.A;
            fillColor.Red          = polygonKml.FillColor.R;
            fillColor.Green        = polygonKml.FillColor.G;
            fillColor.Blue         = polygonKml.FillColor.B;
            this.opacity           = polygonKml.FillColor.A;

            IRgbColor outlineColor = new RgbColorClass();
            outlineColor.Transparency = polygonKml.OutLineColor.A;
            outlineColor.Red          = polygonKml.OutLineColor.R;
            outlineColor.Green        = polygonKml.OutLineColor.G;
            outlineColor.Blue         = polygonKml.OutLineColor.B;

            simpleLineSymbol.Color   = outlineColor;
            simpleLineSymbol.Width   = polygonKml.OutLineSize;
            simpleFillSymbol.Color   = fillColor;
            simpleFillSymbol.Outline = simpleLineSymbol;

            this.fillColor    = polygonKml.FillColor;
            this.outlineColor = polygonKml.OutLineColor;
            this.outLineSize  = polygonKml.OutLineSize;

            #endregion

            #region  位置

            IGeometry        geometry        = new PolygonClass();
            IPointCollection pointCollection = geometry as IPointCollection;
            IPoint           point           = new PointClass();
            foreach (var item in polygonKml.PositionList)
            {
                point.PutCoords(item.Lng, item.Lat);
                point.Z = item.Alt;
                pointCollection.AddPoint(point);
            }

            (pointCollection as IZAware).ZAware = true;

            #endregion

            base.Geometry = pointCollection as IGeometry;           //指定位置
            base.Symbol   = simpleFillSymbol;                       //指定符号

            flashTimer          = new System.Timers.Timer();
            flashTimer.Elapsed += new System.Timers.ElapsedEventHandler(flashTimer_Elapsed);
            flashTimer.Interval = 500;
        }
Пример #11
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);
            }
        }
Пример #12
0
        public void SymbolInit()
        {
            IRgbColor pFcolor     = new RgbColorClass();
            IRgbColor pOcolor     = new RgbColorClass();
            IRgbColor pTrackcolor = new RgbColorClass();
            IRgbColor pVcolor     = new RgbColorClass();

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

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

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

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

            m_MarkerSym              = new SimpleMarkerSymbolClass();
            m_MarkerSym.Style        = esriSimpleMarkerStyle.esriSMSCircle;
            m_MarkerSym.Color        = pFcolor;
            m_MarkerSym.Outline      = true;
            m_MarkerSym.OutlineColor = pOcolor;
            m_MarkerSym.OutlineSize  = ScaleChange(1, m_pMap);

            m_VertexSym       = new SimpleMarkerSymbolClass();
            m_VertexSym.Style = esriSimpleMarkerStyle.esriSMSSquare;
            m_VertexSym.Color = pVcolor;
            m_VertexSym.Size  = ScaleChange(4, m_pMap);

            m_EndPointSym       = new SimpleMarkerSymbolClass();
            m_EndPointSym.Style = esriSimpleMarkerStyle.esriSMSSquare;
            m_EndPointSym.Color = pFcolor;
            m_EndPointSym.Size  = ScaleChange(4, m_pMap);

            m_LineSym       = new SimpleLineSymbolClass();
            m_LineSym.Style = esriSimpleLineStyle.esriSLSSolid;
            m_LineSym.Color = pFcolor;
            m_LineSym.Width = ScaleChange(1, m_pMap);

            m_TracklineSym       = new SimpleLineSymbolClass();
            m_TracklineSym.Color = pTrackcolor;
            m_TracklineSym.Width = ScaleChange(1, m_pMap);

            m_Osym       = new SimpleLineSymbolClass();
            m_Osym.Color = pOcolor;
            m_Osym.Width = ScaleChange(1, m_pMap);

            m_FillSym         = new SimpleFillSymbolClass();
            m_FillSym.Color   = pFcolor;
            m_FillSym.Style   = esriSimpleFillStyle.esriSFSVertical;
            m_FillSym.Outline = m_Osym;
        }
Пример #13
0
 /// <summary>
 /// Gets a XElement class representing a symbol of a graphic box.
 /// </summary>
 /// <param name="type">Type of symbol</param>
 /// <param name="symbol">Render symbol</param>
 /// <param name="customRender">A value indicating whether the custom render is used.</param>
 /// <returns></returns>
 private static XElement GetBoxSymbolXElement(string type, ISimpleFillSymbol symbol, bool customRender = false)
 {
     return(new XElement(type,
                         GetColorXElement("fill", symbol.Color),
                         GetColorXElement("outline", symbol.Outline.Color),
                         new XElement("outlinewidth", symbol.Outline.Width.ToString()),
                         new XElement("style", Convert.ToString((int)symbol.Style)),
                         new XElement("customrender", customRender.ToString())));
 }
Пример #14
0
        public void LayerRender()
        {
            try
            {
                //IFeatureLayer pFeatureLayer = featLayer;
                IGeoFeatureLayer     pGeoFeatureLayer     = featLayer as IGeoFeatureLayer;
                IFeatureClass        pFeatureClass        = featLayer.FeatureClass;         //获取图层上的featureClass
                IFeatureCursor       pFeatureCursor       = pFeatureClass.Search(null, false);
                IUniqueValueRenderer pUniqueValueRenderer = new UniqueValueRendererClass(); //唯一值渲染器
                //设置渲染字段对象
                pUniqueValueRenderer.FieldCount = 1;
                pUniqueValueRenderer.set_Field(0, fieldName);
                ISimpleFillSymbol pSimFillSymbol = new SimpleFillSymbolClass();   //创建填充符号
                pUniqueValueRenderer.DefaultSymbol    = (ISymbol)pSimFillSymbol;
                pUniqueValueRenderer.UseDefaultSymbol = false;
                int n = pFeatureClass.FeatureCount(null);
                for (int i = 0; i < n; i++)
                {
                    IFeature          pFeature          = pFeatureCursor.NextFeature();
                    IClone            pSourceClone      = pSimFillSymbol as IClone;
                    ISimpleFillSymbol pSimpleFillSymbol = pSourceClone.Clone() as ISimpleFillSymbol;
                    string            pFeatureValue     = pFeature.get_Value(pFeature.Fields.FindField(fieldName)).ToString();
                    pUniqueValueRenderer.AddValue(pFeatureValue, "", (ISymbol)pSimpleFillSymbol);
                }

                //为每个符号设置颜色

                for (int i = 0; i <= pUniqueValueRenderer.ValueCount - 1; i++)
                {
                    string xv = pUniqueValueRenderer.get_Value(i);

                    if (xv != "")
                    {
                        ISimpleFillSymbol pNextSymbol = (ISimpleFillSymbol)pUniqueValueRenderer.get_Symbol(xv);
                        pNextSymbol.Color = colorRamp.get_Color(i * (colorRamp.Size / pUniqueValueRenderer.ValueCount));
                        pUniqueValueRenderer.set_Symbol(xv, (ISymbol)pNextSymbol);
                        if (xv.Contains("."))
                        {
                            pUniqueValueRenderer.set_Label(xv, xv.Substring(0, xv.IndexOf(".") + 4));
                        }
                        else
                        {
                            pUniqueValueRenderer.set_Label(xv, xv);
                        }
                    }
                }

                pGeoFeatureLayer.Renderer = (IFeatureRenderer)pUniqueValueRenderer;
                axmapcontrol.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                axtoccontrol.Update();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Пример #15
0
        public static ISymbol GenerateLayerSymbol(LayerDef layerDef,
                                                  GeometryType geometryType)
        {
            if (layerDef == null)
            {
                return(GetDefaultSymbol(geometryType));
            }

            if (layerDef.GeometryType == GeometryType.Point ||
                layerDef.GeometryType == GeometryType.Multipoint)
            {
                ISimpleLineSymbol outline =
                    Runtime.graphicEngine.newSimpleLineSymbol();
                outline.Color = layerDef.OutlineColor;
                outline.Style = layerDef.LineStyle;
                outline.Width = layerDef.LineWidth;

                ISimpleMarkerSymbol symbol =
                    Runtime.graphicEngine.newSimpleMarkerSymbol();
                symbol.Color   = layerDef.Color;
                symbol.Size    = layerDef.MarkerSize;
                symbol.Style   = layerDef.MarkerStyle;
                symbol.Outline = outline;

                return(symbol);
            }
            else if (layerDef.GeometryType == GeometryType.Polyline)
            {
                ISimpleLineSymbol symbol =
                    Runtime.graphicEngine.newSimpleLineSymbol();
                symbol.Color = layerDef.Color;
                symbol.Style = layerDef.LineStyle;
                symbol.Width = layerDef.LineWidth;

                return(symbol);
            }
            else if (layerDef.GeometryType == GeometryType.Polygon)
            {
                ISimpleLineSymbol outline =
                    Runtime.graphicEngine.newSimpleLineSymbol();
                outline.Color = layerDef.OutlineColor;
                outline.Style = layerDef.LineStyle;
                outline.Width = layerDef.LineWidth;

                ISimpleFillSymbol symbol =
                    Runtime.graphicEngine.newSimpleFillSymbol();
                symbol.Color   = layerDef.Color;
                symbol.Style   = layerDef.FillStyle;
                symbol.Outline = outline;

                return(symbol);
            }

            return(null);
        }
Пример #16
0
        private static void SymbolInit()
        {
            //设置各种地图符号的颜色
            IRgbColor pFcolor;
            IRgbColor pOcolor;
            IRgbColor pTrackcolor;
            IRgbColor pVcolor;
            IRgbColor pSColor;

            pFcolor     = new RgbColor();
            pOcolor     = new RgbColor();
            pTrackcolor = new RgbColor();
            pVcolor     = new RgbColor();
            pSColor     = new RgbColor();
            pFcolor     = MapManager.GetRgbColor(255, 0, 0);
            pOcolor     = MapManager.GetRgbColor(0, 0, 255);
            pTrackcolor = MapManager.GetRgbColor(0, 255, 255);
            pVcolor     = MapManager.GetRgbColor(0, 255, 0);
            pSColor     = MapManager.GetRgbColor(0, 0, 0);
            //设置各种地图符号的属性
            m_markerSym              = new SimpleMarkerSymbol();
            m_markerSym.Style        = esriSimpleMarkerStyle.esriSMSCircle;
            m_markerSym.Color        = pFcolor;
            m_markerSym.Outline      = true;
            m_markerSym.OutlineColor = pOcolor;
            m_markerSym.OutlineSize  = 1;
            m_vertexSym              = new SimpleMarkerSymbol();
            m_vertexSym.Style        = esriSimpleMarkerStyle.esriSMSSquare;
            m_vertexSym.Color        = pVcolor;
            m_vertexSym.Size         = 4;
            m_selPointSym            = new SimpleMarkerSymbol();
            m_selPointSym.Style      = esriSimpleMarkerStyle.esriSMSSquare;
            m_selPointSym.Color      = pSColor;
            m_selPointSym.Size       = 4;
            m_endPointSym            = new SimpleMarkerSymbol();
            m_endPointSym.Style      = esriSimpleMarkerStyle.esriSMSSquare;
            m_endPointSym.Color      = pFcolor;
            m_endPointSym.Size       = 4;
            m_lineSym            = new SimpleLineSymbol();
            m_lineSym.Color      = pFcolor;
            m_lineSym.Width      = 1;
            m_tracklineSym       = new SimpleLineSymbol();
            m_tracklineSym.Color = pTrackcolor;
            m_tracklineSym.Width = 1;
            ISimpleLineSymbol pOsym = default(ISimpleLineSymbol);

            pOsym             = new SimpleLineSymbol();
            pOsym.Color       = pOcolor;
            pOsym.Width       = 1;
            m_fillSym         = new SimpleFillSymbol();
            m_fillSym.Color   = pFcolor;
            m_fillSym.Style   = esriSimpleFillStyle.esriSFSVertical;
            m_fillSym.Outline = pOsym;
        }
Пример #17
0
        // Get the default fill symbol - light cyan fill
        public static ISimpleFillSymbol GetDefaultFillSymbol()
        {
            ISimpleLineSymbol lineSymbol = GetDefaultLineSymbol();

            if (_defaultFillSymbol == null)
            {
                _defaultFillSymbol = Runtime.graphicEngine.newSimpleFillSymbol(
                    Colors.LightCyan, SimpleFillStyle.Solid, lineSymbol);
            }
            return(_defaultFillSymbol);
        }
Пример #18
0
        //初始化gridview控件
        private void initialupdatagrid()
        {
            for (int i = 0; i < ptinColorRampRenderer.BreakCount; i++)
            {
                DataRow row = dataTable2.NewRow();
                row[1] = ptinColorRampRenderer.get_Label(i);
                row[2] = row[1];
                dataTable2.Rows.Add(row);

                ISimpleFillSymbol pSymbol = ptinColorRampRenderer.get_Symbol(i) as ISimpleFillSymbol;
                datagridsymbol.Rows[i].Cells[0].Style.BackColor = ClsGDBDataCommon.IColorToColor(pSymbol.Color);
            }
            datagridsymbol.CurrentCell = null;
        }
Пример #19
0
        /// <summary>
        /// Draw box symbol at the given position.
        /// </summary>
        /// <param name="pos">Position of pixel</param>
        /// <param name="activeLayer">Raster layer to add symbol</param>
        /// <param name="refresh">An value indicating whether to refresh screen after adding symbol</param>
        /// <param name="symbol">Symbol style</param>
        public static IElement DrawBox(Position pos, ISimpleFillSymbol symbol, ILayer activeLayer, bool refresh = false)
        {
            if (activeLayer != null)
            {
                IElement element = DrawBoxElement(symbol, pos, activeLayer);

                if (refresh)
                {
                    ArcMap.Document.ActiveView.Refresh();
                }

                return(element);
            }

            return(null);
        }
Пример #20
0
        // *************************************************************************

        /// <summary>
        /// 在地图上绘制形状
        /// </summary>
        /// <param name="geometry">需要绘制的形状</param>
        /// <param name="mapControl">绘制目标(地图控件接口)</param>
        public static void DrawMapShape(IGeometry geometry, IMapControl2 mapControl)
        {
            ISimpleLineSymbol pSymbol_line = getLineSymbol();
            ISimpleFillSymbol pSymbol_fill = getFillSymbol(pSymbol_line);
            object            oSymbol;

            if (geometry.GeometryType == esriGeometryType.esriGeometryPolyline)
            {
                oSymbol = pSymbol_line;
            }
            else
            {
                oSymbol = pSymbol_fill;
            }
            mapControl.DrawShape(geometry, ref oSymbol);
        }
Пример #21
0
        private static IElement CreateFillElement(IGeometry pGeometry, ISimpleFillSymbol pFillSym)
        {
            IFillShapeElement pFillEle = new RectangleElementClass();
            pFillEle.Symbol = pFillSym;
            IElement pElement = pFillEle as IElement;

            pElement.Geometry = pGeometry;

            IScreenDisplay pScrDisp = ArcMap.Document.ActiveView.ScreenDisplay;
            pElement.Activate(pScrDisp);

            pScrDisp.StartDrawing(0, (System.Int16)esriScreenCache.esriNoScreenCache);
            pElement.Draw(pScrDisp, null);
            pScrDisp.FinishDrawing();

            return pElement;
        }
Пример #22
0
        private void SimpleRenderFlyr()
        {
            ISimpleFillSymbol simpleFillSymbol = SymbolWorker.CreateSimpleFillSymbol() as ISimpleFillSymbol;
            ISimpleRenderer   simpleRender     = new SimpleRendererClass();

            simpleRender.Symbol      = simpleFillSymbol as ISymbol;
            simpleRender.Label       = "Continents";
            simpleRender.Description = "简单渲染";
            IGeoFeatureLayer geoFeatureLayer;

            geoFeatureLayer = getGeoLayer("Continents");
            ITransparencyRenderer transRenderer;

            transRenderer = simpleRender as ITransparencyRenderer;
            transRenderer.TransparencyField = "SQMI";
            geoFeatureLayer.Renderer        = transRenderer as IFeatureRenderer;
        }
Пример #23
0
        private void SetDefaultDymbol()
        {
            IColor            color      = (IColor)ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.Black);
            ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass();

            lineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
            lineSymbol.Width = 1.0;
            lineSymbol.Color = color;

            color = (IColor)ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.Navy);
            if (null == m_fillSymbol)
            {
                m_fillSymbol = new SimpleFillSymbolClass();
            }
            m_fillSymbol.Color   = color;
            m_fillSymbol.Style   = esriSimpleFillStyle.esriSFSSolid;
            m_fillSymbol.Outline = (ILineSymbol)lineSymbol;
        }
Пример #24
0
        private void mnuColor_Click(object sender, EventArgs e)
        {
            ILayer pLayer = MainMap.get_Layer(0);

            IGeoFeatureLayer  pGeoFeatureLayer = pLayer as IGeoFeatureLayer;
            IFeatureRenderer  pFeatureRender   = pGeoFeatureLayer.Renderer;
            ISimpleRenderer   pSimpleRender    = pFeatureRender as ISimpleRenderer;
            ISimpleFillSymbol pSym             = pSimpleRender.Symbol as ISimpleFillSymbol;

            IRgbColor pRGBColor = new RgbColorClass();

            pRGBColor.Red   = 200;
            pRGBColor.Green = 10;
            pRGBColor.Blue  = 50;

            pSym.Color = pRGBColor as IColor;
            MainMap.ActiveView.Refresh();
        }
Пример #25
0
        public void InitMainMap(object control)
        {
            if (_activeView != null)
            {
                _activeViewEvents.ViewRefreshed -= ActiveViewEventsOnViewRefreshed;
            }
            if (mapControlEvents2 != null)
            {
                mapControlEvents2.OnViewRefreshed -= MapControlEvents2OnOnViewRefreshed;
                mapControlEvents2.OnExtentUpdated -= MapControlEvents2OnOnExtentUpdated;
            }
            if (control is IPageLayoutControl2)
            {
                _map = _context.FocusMap;
                _activeViewEvents = _context.FocusMap as IActiveViewEvents_Event;
                _activeViewEvents.ViewRefreshed += ActiveViewEventsOnViewRefreshed;
            }
            else if (control is IMapControl3)
            {
                _mainMapControl   = control as IMapControl2;
                _map              = _mainMapControl.Map;
                mapControlEvents2 = _mainMapControl as IMapControlEvents2_Event;
                mapControlEvents2.OnViewRefreshed += MapControlEvents2OnOnViewRefreshed;
                mapControlEvents2.OnExtentUpdated += MapControlEvents2OnOnExtentUpdated;
            }

            _rectangleElement = new RectangleElementClass();
            _fillSymbol       = new SimpleFillSymbolClass();
            _fillSymbol.Style = esriSimpleFillStyle.esriSFSNull;
            ILineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
            IRgbColor   color            = new RgbColorClass()
            {
                Red   = 0,
                Green = 0,
                Blue  = 255
            };

            simpleLineSymbol.Color = color;
            simpleLineSymbol.Width = 2;
            _fillSymbol.Outline    = simpleLineSymbol;
            ((IFillShapeElement)_rectangleElement).Symbol = _fillSymbol;
            axMapControl1.ActiveView.GraphicsContainer.AddElement(_rectangleElement as IElement, 0);
            _canDo = true;
        }
Пример #26
0
        private void SetDefaultDymbol()
        {
            IColor            rGBColor = ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.Black);
            ISimpleLineSymbol simpleLineSymbolClass = new SimpleLineSymbol()
            {
                Style = esriSimpleLineStyle.esriSLSSolid,
                Width = 1,
                Color = rGBColor
            };

            rGBColor = ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.Navy);
            if (null == this.m_fillSymbol)
            {
                this.m_fillSymbol = new SimpleFillSymbol();
            }
            this.m_fillSymbol.Color   = rGBColor;
            this.m_fillSymbol.Style   = esriSimpleFillStyle.esriSFSSolid;
            this.m_fillSymbol.Outline = simpleLineSymbolClass;
        }
        private static IElement CreateFillElement(IGeometry pGeometry, ISimpleFillSymbol pFillSym)
        {
            IFillShapeElement pFillEle = new RectangleElementClass();

            pFillEle.Symbol = pFillSym;
            IElement pElement = pFillEle as IElement;

            pElement.Geometry = pGeometry;

            IScreenDisplay pScrDisp = ArcMap.Document.ActiveView.ScreenDisplay;

            pElement.Activate(pScrDisp);

            pScrDisp.StartDrawing(0, (System.Int16)esriScreenCache.esriNoScreenCache);
            pElement.Draw(pScrDisp, null);
            pScrDisp.FinishDrawing();

            return(pElement);
        }
Пример #28
0
        public override void OnDblClick()
        {
            if (this._polygonFeedback != null)
            {
                IPolygon          polygon          = this._polygonFeedback.Stop();
                ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol();
                ISimpleFillSymbol arg_3E_0         = simpleFillSymbol;
                IRgbColor         rgbColorClass    = ColorManage.CreatColor(255, 0, 0) as IRgbColor;
                arg_3E_0.Color = rgbColorClass;
                if (polygon != null)
                {
                    CommonUtils.NewPolygonElement(_context.FocusMap, polygon);
                }
            }
            int pointCount = this._pointCollection.PointCount;

            this._pointCollection.RemovePoints(0, pointCount);
            this._polygonFeedback = null;
        }
Пример #29
0
        // Get a default fill symbol by index.
        // Note: all default fill symbols share a common line symbol:
        // black and solid line with 1.0 width.
        // You can change the line symbol by specifiying Outline property.
        public static ISimpleFillSymbol GetDefaultFillSymbols(int index)
        {
            Color[]           defaultColors = ColorRamp.GetColorRamp(ColorRampEnum.Default);
            int               size          = defaultColors.Count();
            ISimpleLineSymbol lineSymbol    = GetDefaultLineSymbol();

            if (_defaultFillSymbols == null)
            {
                _defaultFillSymbols = new ISimpleFillSymbol[size];
                for (int i = 0; i < size; ++i)
                {
                    ISimpleFillSymbol symbol = Runtime.graphicEngine.newSimpleFillSymbol(
                        defaultColors[i],
                        IS3.Core.Graphics.SimpleFillStyle.Solid,
                        lineSymbol);
                    _defaultFillSymbols[i] = symbol;
                }
            }
            return(_defaultFillSymbols[index % size]);
        }
Пример #30
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     if (flashTimer != null)
     {
         flashTimer.Stop();
         flashTimer.Dispose();
         flashTimer = null;
     }
     layer            = null;
     mapControl       = null;
     graphicsLayer    = null;
     simpleFillSymbol = null;
     simpleLineSymbol = null;
     index            = -1;
     isHightLight     = false;
     isFlash          = false;
     isVisible        = true;
     isTimer          = false;
     lockObj          = null;
     properties       = null;
 }
Пример #31
0
        public RenderLayerFill(IFeatureLayer featureLayer, MainForm frm)
        {
            InitializeComponent();
            m_featureLayer = featureLayer;
            m_fraMain      = frm;

            //Get properties of the current symbol
            IGeoFeatureLayer geoFeatureLayer = featureLayer as IGeoFeatureLayer;
            IFeatureRenderer featureRenderer = geoFeatureLayer.Renderer;

            if (featureRenderer is ISimpleRenderer)
            {
                ISimpleRenderer   simpleRenderer   = geoFeatureLayer.Renderer as ISimpleRenderer;
                ISimpleFillSymbol simpleFillSymbol = simpleRenderer.Symbol as ISimpleFillSymbol;

                if (simpleFillSymbol != null)
                {
                    //Get the width of outline
                    tbOutlineWidth.Text = simpleFillSymbol.Outline.Width.ToString();


                    //Get the fill color
                    IRgbColor rgbColorFill = new RgbColorClass();
                    rgbColorFill     = simpleFillSymbol.Color as IRgbColor;
                    tbRedFill.Text   = rgbColorFill.Red.ToString();
                    tbGreenFill.Text = rgbColorFill.Green.ToString();
                    tbBlueFill.Text  = rgbColorFill.Blue.ToString();

                    //Get the color of outline
                    IRgbColor rgbColorOutline = new RgbColorClass();
                    rgbColorOutline     = simpleFillSymbol.Outline.Color as IRgbColor;
                    tbRedOutline.Text   = rgbColorOutline.Red.ToString();
                    tbGreenOutline.Text = rgbColorOutline.Green.ToString();
                    tbBlueOutline.Text  = rgbColorOutline.Blue.ToString();

                    //Change the value of track bar
                    tkbOutlineWidth.Value = (int)System.Convert.ToDouble(tbOutlineWidth.Text);
                }
            }
        }
Пример #32
0
 /// <summary>
 /// Gets a XElement class representing a symbol of a graphic box.
 /// </summary>
 /// <param name="type">Type of symbol</param>
 /// <param name="symbol">Render symbol</param>
 /// <param name="customRender">A value indicating whether the custom render is used.</param>
 /// <returns></returns>
 private static XElement GetBoxSymbolXElement(string type, ISimpleFillSymbol symbol, bool customRender = false)
 {
     return new XElement(type,
                         GetColorXElement("fill", symbol.Color),
                         GetColorXElement("outline", symbol.Outline.Color),
                         new XElement("outlinewidth", symbol.Outline.Width.ToString()),
                         new XElement("style", Convert.ToString((int)symbol.Style)),
                         new XElement("customrender", customRender.ToString()));
 }
Пример #33
0
 // Get the default fill symbol - light cyan fill
 public static ISimpleFillSymbol GetDefaultFillSymbol()
 {
     ISimpleLineSymbol lineSymbol = GetDefaultLineSymbol();
     if (_defaultFillSymbol == null)
     {
         _defaultFillSymbol = Runtime.graphicEngine.newSimpleFillSymbol(
             Colors.LightCyan, SimpleFillStyle.Solid, lineSymbol);
     }
     return _defaultFillSymbol;
 }
    public void Load(IVariantStream Stream)
    {
      int ver = (int)Stream.Read();
      if (ver > c_Version || ver <= 0)
        throw new Exception("Wrong version!");

      InitMembers();

      m_size = (double)Stream.Read();
      m_scaleRef = (double)Stream.Read();
      m_anchorPointType = (esriAnchorPointEnum)Stream.Read();
      m_autoTrans = (bool)Stream.Read();
      m_elementType = (string)Stream.Read();
      m_elementName = (string)Stream.Read();
      m_nativeSR = Stream.Read() as ISpatialReference;
      m_fillSymbol = Stream.Read() as ISimpleFillSymbol;
      m_pointGeometry = Stream.Read() as IPoint;
      m_triangle = Stream.Read() as IPolygon;

      if (ver == 2)
      {
        m_rotation = (double)Stream.Read();
      }
    }
Пример #35
0
        /// <summary>
        /// Loads the editor configuration from file.
        /// </summary>
        public static void Load()
        {
            if (!File.Exists(ConfigFile))
            {
                Create();
                isLoaded = true;
                return;
            }

            XDocument config = XDocument.Load(ConfigFile);

            Color wColor;
            XElement selectionSymbolNode = config.Root.Element("symbol").Element("selection");
            selectionSymbol = new SimpleFillSymbolClass();
            ISimpleLineSymbol selectionOutlineSymbol = new SimpleLineSymbolClass();
            foreach (XElement xmlColor in selectionSymbolNode.Elements("color"))
            {
                wColor = ColorTranslator.FromHtml(xmlColor.Value);
                IColor arcColor = new RgbColorClass()
                    {
                        Red = wColor.R,
                        Green = wColor.G,
                        Blue = wColor.B,
                        Transparency = Convert.ToByte(xmlColor.Attribute("transparency").Value),
                        NullColor = Convert.ToBoolean(xmlColor.Attribute("nullcolor").Value)
                    };
                if (xmlColor.Attribute("type").Value == "fill")
                {
                    selectionSymbol.Color = arcColor;
                }
                else
                {
                    selectionOutlineSymbol.Color = arcColor;
                }
            }
            selectionOutlineSymbol.Width = Convert.ToDouble(selectionSymbolNode.Element("outlinewidth").Value);
            selectionSymbol.Outline = selectionOutlineSymbol;
            selectionSymbol.Style = (esriSimpleFillStyle)(Convert.ToInt32(selectionSymbolNode.Element("style").Value));

            XElement editSymbolNode = config.Root.Element("symbol").Element("edit");
            editSymbol = new SimpleFillSymbolClass();
            ISimpleLineSymbol editOutlieSymbol = new SimpleLineSymbolClass();
            foreach (XElement xmlColor in editSymbolNode.Elements("color"))
            {
                wColor = ColorTranslator.FromHtml(xmlColor.Value);
                IColor arcColor = new RgbColorClass()
                {
                    Red = wColor.R,
                    Green = wColor.G,
                    Blue = wColor.B,
                    Transparency = Convert.ToByte(xmlColor.Attribute("transparency").Value),
                    NullColor = Convert.ToBoolean(xmlColor.Attribute("nullcolor").Value)
                };
                if (xmlColor.Attribute("type").Value == "fill")
                {
                    editSymbol.Color = arcColor;
                }
                else
                {
                    editOutlieSymbol.Color = arcColor;
                }
            }
            editOutlieSymbol.Width = Convert.ToDouble(editSymbolNode.Element("outlinewidth").Value);
            editSymbol.Outline = editOutlieSymbol;
            editSymbol.Style = (esriSimpleFillStyle)(Convert.ToInt32(editSymbolNode.Element("style").Value));
            customEditRender = Convert.ToBoolean(editSymbolNode.Element("customrender").Value);

            isLoaded = true;
        }
Пример #36
0
        /// <summary>
        /// Draw box symbol at the given position.
        /// </summary>
        /// <param name="pos">Position of pixel</param>
        /// <param name="activeLayer">Raster layer to add symbol</param>
        /// <param name="refresh">An value indicating whether to refresh screen after adding symbol</param>
        /// <param name="symbol">Symbol style</param>
        public static IElement DrawBox(Position pos, ISimpleFillSymbol symbol, ILayer activeLayer, bool refresh = false)
        {
            if (activeLayer != null)
            {
                IElement element = DrawBoxElement(symbol, pos, activeLayer);

                if (refresh)
                {
                    Refresh();
                }

                return element;
            }

            return null;
        }
Пример #37
0
        /// <summary>
        /// Drawing the graphic element of the pixel box.
        /// </summary>
        /// <param name="boxSymbol">The graphic symbol of the drawing box.</param>
        /// <param name="pixelPos">The postion of drawing cell.</param>
        /// <param name="activeLayer">Raster layer to be symbolized.</param>
        /// <returns>An IFillShapeElement implimentation as IElement</returns>
        private static IElement DrawBoxElement(ISimpleFillSymbol boxSymbol, Position pixelPos, ILayer activeLayer = null)
        {
            // Probably should be removed.
            ILayer layer = activeLayer == null ? Editor.ActiveLayer : activeLayer;

            IActiveView activeView = ArcMap.Document.ActiveView;

            IFillShapeElement fillShapeElement = new RectangleElementClass();
            fillShapeElement.Symbol = (IFillSymbol)boxSymbol;

            // Retrive the cell coordinate and the cell size
            double x, y;
            IRasterLayer rasterLayer = (IRasterLayer)layer;
            IRaster2 raster = (IRaster2)rasterLayer.Raster;
            raster.PixelToMap(pixelPos.Column, pixelPos.Row, out x, out y);
            IRasterProps rasterProp = (IRasterProps)raster;
            IPnt cellSize = rasterProp.MeanCellSize();

            // Define the extent of the selection box
            IEnvelope envelop = new EnvelopeClass();
            envelop.XMin = x - cellSize.X / 2;
            envelop.XMax = x + cellSize.X / 2;
            envelop.YMin = y - cellSize.Y / 2;
            envelop.YMax = y + cellSize.Y / 2;

            IElement element = (IElement)fillShapeElement;
            element.Geometry = (IGeometry)envelop;

            activeView.GraphicsContainer.AddElement(element, 0);

            return element;
        }
    private void SetDefaultDymbol()
    {
      IColor color = (IColor)ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.Black);
      ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass();
      lineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
      lineSymbol.Width = 1.0;
      lineSymbol.Color = color;

      color = (IColor)ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.Navy);
      if (null == m_fillSymbol)
        m_fillSymbol = new SimpleFillSymbolClass();
      m_fillSymbol.Color = color;
      m_fillSymbol.Style = esriSimpleFillStyle.esriSFSSolid;
      m_fillSymbol.Outline = (ILineSymbol)lineSymbol;
    }
Пример #39
0
        void IThematic.SingleRender()
        {
            //_ftLayer = (IFeatureLayer)_mapControl.get_Layer(0);
            _geoFeatureLayer = (IGeoFeatureLayer)_ftLayer;
            _ftClass = _ftLayer.FeatureClass;
            _table = (ITable)_ftClass;

            _interval = (this._maxValue - this._minValue) / this._breakCount;

            _renderer.Field = _fieldName;
            _renderer.BreakCount = _breakCount;
            _renderer.SortClassesAscending = true;

            _colorFrom.Hue = 60;
            _colorFrom.Saturation = 100;
            _colorFrom.Value = 96;

            _colorTo.Hue = 0;
            _colorTo.Saturation = 100;
            _colorTo.Value = 96;

            _algClrRamp.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;
            _algClrRamp.FromColor = _colorFrom;
            _algClrRamp.ToColor = _colorTo;
            _algClrRamp.Size = _breakCount;
            bool ok;
            _algClrRamp.CreateRamp(out ok);
            _enumColors = _algClrRamp.Colors;

            IColor pColor;
            _currentValue = _minValue;//_renderer.MinimumBreak;

            for (int breakIndex = 0; breakIndex < _breakCount; breakIndex++)
            {

                pColor = _enumColors.Next();
                _symbol = new SimpleFillSymbolClass();
                _symbol.Color = pColor;
                _symbol.Style = esriSimpleFillStyle.esriSFSSolid;

                _renderer.set_Break(breakIndex, _currentValue);

                _renderer.set_Symbol(breakIndex, (ISymbol)_symbol);
                _currentValue += _interval;
            }
            _mapControl.AddLayer(_ftLayer,0);
            _geoFeatureLayer.Renderer = (IFeatureRenderer)_renderer;
            _mapControl.ActiveView.Refresh();
            _tocControl.Update();
            //_tableHistogram.Field = _fieldName;
            //_tableHistogram.Table = _table;

            //_classify.
        }
Пример #40
0
        /// <summary>
        /// Resets the default configuration.
        /// </summary>
        public static void SetDefault()
        {
            selectionSymbol = new SimpleFillSymbolClass();
            selectionSymbol.Color = new RgbColorClass() { NullColor = true, Transparency = 0 };
            ISimpleLineSymbol selectionOutlineSymbol = new SimpleLineSymbolClass();
            selectionOutlineSymbol.Color = new RgbColorClass() { Red = 0, Green = 255, Blue = 255};
            selectionOutlineSymbol.Width = 2;
            selectionSymbol.Outline = selectionOutlineSymbol;

            customEditRender = false;
            editSymbol = new SimpleFillSymbolClass();
            editSymbol.Color = new RgbColorClass() { Red = 255, Green = 255, Blue = 90, Transparency = 127 };
            ISimpleLineSymbol editOutlineSymbol = new SimpleLineSymbolClass();
            editOutlineSymbol.Color = new RgbColorClass() { Red = 255, Green = 255, Blue = 0 };
            editOutlineSymbol.Width = 2;
            editSymbol.Style = esriSimpleFillStyle.esriSFSBackwardDiagonal;
            editSymbol.Outline = editOutlineSymbol;
        }
Пример #41
0
    private void applyRenderer(IGeoFeatureLayer geoLayer, IServerContext mapContext, string fieldName, Classifier classifier)
    {
        IClassBreaksRenderer cbRenderer = (IClassBreaksRenderer)mapContext.CreateObject("esriCarto.ClassBreaksRenderer");
        cbRenderer.Field = fieldName;

        ILegendInfo legendInfo = (ILegendInfo)cbRenderer;
        ILegendGroup legendGroup = legendInfo.get_LegendGroup(0);
        legendGroup.Heading = "Counts";

        int breaks = classifier.getBreaks();
        IColor [] pColors = new IColor[breaks];
        ISimpleFillSymbol [] symbols = new ISimpleFillSymbol[breaks];

        double breakValue;
        cbRenderer.BreakCount = breaks;
        IAlgorithmicColorRamp colorRamp = (IAlgorithmicColorRamp)mapContext.CreateObject("esriDisplay.AlgorithmicColorRamp");
        IColor startColor, endColor;

        startColor = createRGBColor(mapContext, 255, 255, 0);
        endColor = createRGBColor(mapContext, 255, 0, 0);
        colorRamp.FromColor = startColor;
        colorRamp.ToColor = endColor;
        colorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
        colorRamp.Size = breaks;
        bool created;
        try
        {
            colorRamp.CreateRamp(out created);
        }
        catch
        {
            this.Label2.Text = "There is not enough data associated with the current extents and attributes selected. A map was not generated. Please try selecting other attributes.";
            return;
        }
        IEnumColors iterColors = colorRamp.Colors;

        double[] classBreaksArray = (double[])classifier.getClassBreaksArray();

        for (int i = 0; i < breaks; i++)
        {
            pColors[i] = iterColors.Next();
            symbols[i] = (ISimpleFillSymbol)mapContext.CreateObject("esriDisplay.SimpleFillSymbol");
            symbols[i].Color = pColors[i];
            cbRenderer.set_Symbol(i, (ISymbol)symbols[i]);

            breakValue = classBreaksArray[i + 1];
            cbRenderer.set_Break(i, breakValue);
            string breakValueString = String.Format("{0:0.00}", breakValue);

            if (i == 0)
            {
                cbRenderer.set_Label(i, "<" + breakValueString);
            }
            else
            {
                string prevValueString = String.Format("{0:0.00}", classBreaksArray[i]);
                string label = prevValueString + " < " + breakValueString;
                cbRenderer.set_Label(i, label);
            }

        }

        geoLayer.Renderer = (IFeatureRenderer)cbRenderer;
        this.Toc1.ExpandDepth = 1;
        this.Toc1.Refresh();
    }
    public void Assign(IClone src)
    {

      //1. make sure that src is pointing to a valid object
      if (null == src)
      {
        throw new COMException("Invalid object.");
      }

      //2. make sure that the type of src is of type 'TriangleElementClass'
      if (!(src is TriangleElementClass))
      {
        throw new COMException("Bad object type.");
      }

      //3. assign the properties of src to the current instance
      TriangleElementClass srcTriangle = (TriangleElementClass)src;
      m_elementName = srcTriangle.Name;
      m_elementType = srcTriangle.Type;
      m_autoTrans = srcTriangle.AutoTransform;
      m_scaleRef = srcTriangle.ReferenceScale;
      m_rotation = srcTriangle.Angle;
      m_size = srcTriangle.Size;
      m_anchorPointType = srcTriangle.AnchorPoint;

      IObjectCopy objCopy = new ObjectCopyClass();

      //take care of the custom property
      if (null != srcTriangle.CustomProperty)
      {
        if (srcTriangle.CustomProperty is IClone)
          m_customProperty = (object)((IClone)srcTriangle.CustomProperty).Clone();
        else if (srcTriangle.CustomProperty is IPersistStream)
        {
          m_customProperty = objCopy.Copy((object)srcTriangle.CustomProperty);
        }
        else if (srcTriangle.CustomProperty.GetType().IsSerializable)
        {
          //serialize to a memory stream
          MemoryStream memoryStream = new MemoryStream();
          BinaryFormatter binaryFormatter = new BinaryFormatter();
          binaryFormatter.Serialize(memoryStream, srcTriangle.CustomProperty);
          byte[] bytes = memoryStream.ToArray();

          memoryStream = new MemoryStream(bytes);
          m_customProperty = binaryFormatter.Deserialize(memoryStream);
        }
      }

      if (null != srcTriangle.SpatialReference)
        m_nativeSR = objCopy.Copy(srcTriangle.SpatialReference) as ISpatialReference;
      else
        m_nativeSR = null;

      if (null != srcTriangle.FillSymbol)
      {
        m_fillSymbol = objCopy.Copy(srcTriangle.FillSymbol) as ISimpleFillSymbol;
      }
      else
        m_fillSymbol = null;

      if (null != srcTriangle.Geometry)
      {
        m_triangle = objCopy.Copy(srcTriangle.Geometry) as IPolygon;
        m_pointGeometry = objCopy.Copy(((IArea)m_triangle).Centroid) as IPoint;
      }
      else
      {
        m_triangle = null;
        m_pointGeometry = null;
      }
    }