Exemplo n.º 1
0
        private static void MapUsingSimpleFillRenderer()
        {
            string layerName = CboLayers.GetSelectedLayer();
            ILayer layer     = GetLayerByName(layerName);

            string     colorName = CboColors.GetSelectedColor();
            ICmykColor fillColor = ColorbrewerExtension.GetSingleCMYKColor();

            ISimpleFillSymbol fill = new SimpleFillSymbol();

            fill.Style = esriSimpleFillStyle.esriSFSSolid;
            fill.Color = fillColor;

            ISimpleRenderer simpleRenderer = new SimpleRenderer();

            simpleRenderer.Symbol = fill as ISymbol;
            simpleRenderer.Label  = layer.Name;

            IGeoFeatureLayer gFLayer = layer as IGeoFeatureLayer;

            gFLayer.Renderer = simpleRenderer as IFeatureRenderer;
            IMxDocument mxDoc = ArcMap.Application.Document as IMxDocument;
            IMap        map   = mxDoc.FocusMap;

            mxDoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography
                                            , gFLayer, mxDoc.ActiveView.Extent);
        }
Exemplo n.º 2
0
        private static void MapUsingSimpleMarkerRenderer()
        {
            string layerName = CboLayers.GetSelectedLayer();
            ILayer layer     = GetLayerByName(layerName);

            string     colorName   = CboColors.GetSelectedColor();
            ICmykColor markerColor = ColorbrewerExtension.GetSingleCMYKColor();

            ISimpleMarkerSymbol marker = new SimpleMarkerSymbol();

            marker.Style = esriSimpleMarkerStyle.esriSMSCircle;
            marker.Color = markerColor;
            marker.Size  = 5;

            ISimpleRenderer renderer = new SimpleRenderer();

            renderer.Symbol = marker as ISymbol;
            renderer.Label  = layer.Name;

            IGeoFeatureLayer gFLayer = layer as IGeoFeatureLayer;

            gFLayer.Renderer = renderer as IFeatureRenderer;
            IMxDocument mxDoc = ArcMap.Application.Document as IMxDocument;
            IMap        map   = mxDoc.FocusMap;

            mxDoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography,
                                            gFLayer, mxDoc.ActiveView.Extent);
            mxDoc.UpdateContents();
        }
        internal static ICmykColor[] GetCmykColors()
        {
            try
            {
                string       selectedClass = CboClasses.GetSelectedClass();
                ICmykColor[] colors        = new ICmykColor[Convert.ToInt32(selectedClass)];
                int          currentIndex  = 0;

                string selectedColor = CboColors.GetSelectedColor();

                System.IO.StreamReader file =
                    new System.IO.StreamReader(filepath);
                string line;
                string currentColor = "";
                string currentClass = "";

                while ((line = file.ReadLine()) != null)
                {
                    if (currentIndex == colors.Length)
                    {
                        break;
                    }

                    string[] words = line.Split(',');
                    if (words[0] != "")
                    {
                        currentColor = words[0];
                    }
                    if (words[1] != "")
                    {
                        currentClass = words[1];
                    }
                    if (currentColor.Equals(selectedColor) && currentClass.Equals(selectedClass))
                    {
                        ICmykColor color = new CmykColorClass();
                        color.Cyan           = Convert.ToInt32(words[6]);
                        color.Magenta        = Convert.ToInt32(words[7]);
                        color.Yellow         = Convert.ToInt32(words[8]);
                        color.Black          = Convert.ToInt32(words[9]);
                        colors[currentIndex] = color;
                        currentIndex++;
                    }
                }
                return(colors);
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.ToString());
                LocateCBfile();
                return(GetCmykColors());
            }
        }
Exemplo n.º 4
0
        private static void MapUsingProportionalSymbolRenderer()
        {
            ISimpleMarkerSymbol marker = new SimpleMarkerSymbol();

            marker.Style = esriSimpleMarkerStyle.esriSMSCircle;

            ICmykColor markerColor = ColorbrewerExtension.GetSingleCMYKColor();

            marker.Size  = 10;
            marker.Color = markerColor;

            IMxDocument mxDoc = ArcMap.Application.Document as IMxDocument;
            IMap        map   = mxDoc.FocusMap;

            string          layerName = CboLayers.GetSelectedLayer();
            ILayer          layer     = GetLayerByName(layerName);
            IFeatureLayer   fLayer    = layer as IFeatureLayer;
            IFeatureClass   fClass    = fLayer.FeatureClass as IFeatureClass;
            IFeatureCursor  cursor    = fClass.Search(null, true);
            IDataStatistics dataStats = new DataStatisticsClass();

            dataStats.Cursor = cursor as ICursor;

            string fieldName = CboFields.GetSelectedField();

            dataStats.Field = fieldName;
            IStatisticsResults statResult = dataStats.Statistics;

            IProportionalSymbolRenderer propSymRenderer = new ProportionalSymbolRendererClass();

            propSymRenderer.Field                = fieldName;
            propSymRenderer.MinDataValue         = statResult.Minimum == 0.0 ? 1 : statResult.Minimum;
            propSymRenderer.MaxDataValue         = statResult.Maximum;
            propSymRenderer.FlanneryCompensation = true;
            propSymRenderer.ValueUnit            = esriUnits.esriUnknownUnits;
            propSymRenderer.MinSymbol            = marker as ISymbol;
            propSymRenderer.LegendSymbolCount    = 3;
            propSymRenderer.CreateLegendSymbols();

            IGeoFeatureLayer gFLayer = layer as IGeoFeatureLayer;

            gFLayer.Renderer = propSymRenderer as IFeatureRenderer;
            mxDoc.ActiveView.Refresh();
            mxDoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, gFLayer
                                            , mxDoc.ActiveView.Extent);
            mxDoc.UpdateContents();
        }
Exemplo n.º 5
0
 public ICmykColor GetCmykColor(int iCyan, int iMagenta, int iYellow, int iBlack, bool bUseWinDithering)
 {
     try
     {
         ICmykColor color = null;
         color                     = new CmykColorClass();
         iCyan                     = this.CheckNumValueRegion(iCyan, 0, 0xff);
         iMagenta                  = this.CheckNumValueRegion(iMagenta, 0, 0xff);
         iYellow                   = this.CheckNumValueRegion(iYellow, 0, 0xff);
         iBlack                    = this.CheckNumValueRegion(iBlack, 0, 0xff);
         color.Cyan                = iCyan;
         color.Magenta             = iMagenta;
         color.Yellow              = iYellow;
         color.Black               = iBlack;
         color.UseWindowsDithering = bUseWinDithering;
         return(color);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.ColorFun", "GetCmykColor", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(null);
     }
 }