Example #1
0
        private void mnuSymbol_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;

            ILineFillSymbol pLineFillSymbol = new LineFillSymbolClass();
            ILineSymbol     pLineSymbol     = new SimpleLineSymbolClass();

            IRgbColor pRgbColor = new RgbColorClass();

            pRgbColor.Red   = 96;
            pRgbColor.Green = 96;
            pRgbColor.Blue  = 196;

            pLineSymbol.Color          = pRgbColor as IColor;
            pLineSymbol.Width          = 2;
            pLineFillSymbol.LineSymbol = pLineSymbol;
            pLineFillSymbol.Outline    = pLineSymbol;

            pSimpleRender.Symbol = pLineFillSymbol as ISymbol;
            MainMap.ActiveView.Refresh();
        }
Example #2
0
        //Create Legend
        public void CreateLegend()
        {
            clsSnippet pSnippet = new clsSnippet();

            //Create Legend Group
            m_pLegendGroup = new LegendGroup();

            m_pLegendGroup.Heading  = "Robustness";
            m_pLegendGroup.Editable = true;
            m_pLegendGroup.Visible  = true;

            //For Values
            ILegendClass legendClass = new LegendClass();

            ILineFillSymbol pLineFillSym = new LineFillSymbolClass();



            double dblInstantSep = (dblFromSep - dblToSep) / Convert.ToDouble(intUncernBreakCount - 2);

            for (int i = 0; i < intUncernBreakCount; i++)
            {
                legendClass = new LegendClass();
                if (i == intUncernBreakCount - 1)
                {
                    legendClass.Label = "1";
                }
                else if (i == intUncernBreakCount - 2)
                {
                    legendClass.Label = arrRobustBrks[i].ToString() + " - " + (1 - (1 * Math.Pow(0.1, intRoundingDigits))).ToString();
                }
                else
                {
                    legendClass.Label = arrRobustBrks[i].ToString() + " - " + (arrRobustBrks[i + 1] - (1 * Math.Pow(0.1, intRoundingDigits))).ToString();
                }

                pLineFillSym = new LineFillSymbolClass();

                pLineFillSym.Angle            = dblAngle;
                pLineFillSym.Color            = pLineColor;
                pLineFillSym.LineSymbol.Width = dblLinewidth;
                if (i == (intUncernBreakCount - 1))
                {
                    pLineFillSym.Separation = double.MaxValue;
                }
                else
                {
                    pLineFillSym.Separation = dblToSep + (dblInstantSep * Convert.ToDouble(i));
                }
                legendClass.Symbol = pLineFillSym as ISymbol;
                m_pLegendGroup.AddClass(legendClass);
            }
        }
Example #3
0
        private ILineFillSymbol CreatLineFillSymbol(ILineSymbol fillsymbol, ILineSymbol outlinesymbol, IColor pcolor, double angle, double offset, double septer)
        {
            ILineFillSymbol pLineFillSymbol = new LineFillSymbolClass();

            pLineFillSymbol.LineSymbol = fillsymbol;
            pLineFillSymbol.Outline    = outlinesymbol;
            pLineFillSymbol.Angle      = angle;
            pLineFillSymbol.Color      = pcolor;
            pLineFillSymbol.Offset     = offset;
            pLineFillSymbol.Separation = septer;
            return(pLineFillSymbol);
        }
Example #4
0
        //Draw Symbols by features
        public void Draw(IFeatureCursor pFCursor, esriDrawPhase DrawPhase, IDisplay Display, ITrackCancel trackCancel)
        {
            IFeatureCursor pOriCursor = pFCursor;

            IFeature pFeat = null;

            // do not draw features if no display
            if (Display == null)
            {
                return;
            }

            ILineFillSymbol pLineFillSym = new LineFillSymbolClass();

            pFeat = pFCursor.NextFeature();
            double dblInstantSep = (dblFromSep - dblToSep) / Convert.ToDouble(intUncernBreakCount - 2);

            int i = 0;

            //Start Loop
            while (pFeat != null)
            {
                IFeatureDraw pFeatDraw = (IFeatureDraw)pFeat;
                pLineFillSym                  = new LineFillSymbolClass();
                pLineFillSym.Angle            = dblAngle;
                pLineFillSym.Color            = pLineColor;
                pLineFillSym.LineSymbol.Width = dblLinewidth;

                if (Math.Round(arrRobustness[i], intRoundingDigits) == 1)
                {
                    pLineFillSym.Separation = double.MaxValue;
                }
                else
                {
                    for (int j = 0; j < intUncernBreakCount - 1; j++)
                    {
                        if (arrRobustness[i] >= arrRobustBrks[j] && arrRobustness[i] <= arrRobustBrks[j + 1])
                        {
                            pLineFillSym.Separation = dblToSep + (dblInstantSep * Convert.ToDouble(j));
                        }
                    }
                }


                Display.SetSymbol((ISymbol)pLineFillSym);
                pFeatDraw.Draw(esriDrawPhase.esriDPGeography, Display, (ISymbol)pLineFillSym, true,
                               null, esriDrawStyle.esriDSNormal);
                i++;
                pFeat = pFCursor.NextFeature();
            }
        }
Example #5
0
        void IFeatureRenderer.Draw(ESRI.ArcGIS.Geodatabase.IFeatureCursor Cursor, ESRI.ArcGIS.esriSystem.esriDrawPhase DrawPhase, IDisplay Display, ESRI.ArcGIS.esriSystem.ITrackCancel TrackCancel)
        {
            // do not draw features if no display
            if (Display == null)
            {
                return;
            }
            else
            {
                IFeature pFeat = null;

                intBrksCount = arrClassBrks.Length - 1;
                ILineFillSymbol pLineFillSym = new LineFillSymbolClass();
                pFeat         = Cursor.NextFeature();
                dblInstantSep = (dblFromSep - dblToSep) / Convert.ToDouble(intBrksCount - 1);

                int i = 0;
                //Start Loop
                while (pFeat != null)
                {
                    IFeatureDraw pFeatDraw = (IFeatureDraw)pFeat;
                    pLineFillSym                  = new LineFillSymbolClass();
                    pLineFillSym.Angle            = dblLineAngle;
                    pLineFillSym.Color            = pLineRgb;
                    pLineFillSym.LineSymbol.Width = dblLineWidth;

                    for (int j = 0; j < intBrksCount; j++)
                    {
                        if (arrValue[i] >= arrClassBrks[j] && arrValue[i] <= arrClassBrks[j + 1])
                        {
                            pLineFillSym.Separation = dblToSep + (dblInstantSep * Convert.ToDouble(j));
                        }
                    }

                    Display.SetSymbol((ISymbol)pLineFillSym);
                    pFeatDraw.Draw(esriDrawPhase.esriDPGeography, Display, (ISymbol)pLineFillSym, true,
                                   null, esriDrawStyle.esriDSNormal);
                    i++;
                    pFeat = Cursor.NextFeature();
                }
            }
        }
Example #6
0
        void ISpacingBreaksRenderer.CreateLegend()
        {
            //Create Legend Group
            m_pLegendGroup = new LegendGroup();

            m_pLegendGroup.Heading  = strHeading;
            m_pLegendGroup.Editable = true;
            m_pLegendGroup.Visible  = true;

            intBrksCount  = arrClassBrks.Length - 1;
            dblInstantSep = (dblFromSep - dblToSep) / Convert.ToDouble(intBrksCount - 1);



            //For Values
            ILegendClass legendClass = new LegendClass();

            ILineFillSymbol pLineFillSym = new LineFillSymbolClass();

            for (int i = 0; i < intBrksCount; i++)
            {
                legendClass = new LegendClass();
                //if (i == intUncernBreakCount - 1)
                //    legendClass.Label = "1";
                //else if (i == intUncernBreakCount - 2)
                //    legendClass.Label = arrClassBrks[i].ToString() + " - " + (1 - (1 * Math.Pow(0.1, intRoundingDigits))).ToString();
                //else
                legendClass.Label = Math.Round(arrClassBrks[i], intRoundingDigits).ToString() + " - " + (Math.Round(arrClassBrks[i + 1], intRoundingDigits) - (1 * Math.Pow(0.1, intRoundingDigits))).ToString();

                pLineFillSym = new LineFillSymbolClass();

                pLineFillSym.Angle            = dblLineAngle;
                pLineFillSym.Color            = pLineRgb;
                pLineFillSym.LineSymbol.Width = dblLineWidth;
                pLineFillSym.Separation       = dblToSep + (dblInstantSep * Convert.ToDouble(i));

                legendClass.Symbol = pLineFillSym as ISymbol;
                m_pLegendGroup.AddClass(legendClass);
            }
        }
Example #7
0
        private void btnApply_Click(object sender, EventArgs e)
        {
            try
            {
                string strLayerName = cboSourceLayer.Text;
                if (cboSourceLayer.Text == "" || cboValueField.Text == "" || cboUField.Text == "")
                {
                    MessageBox.Show("Assign proper layer and field");
                    return;
                }

                int    intLIndex = pSnippet.GetIndexNumberFromLayerName(pActiveView, strLayerName);
                ILayer pLayer    = mForm.axMapControl1.get_Layer(intLIndex);

                IFeatureLayer pFLayer = pLayer as IFeatureLayer;
                IFeatureClass pFClass = pFLayer.FeatureClass;

                //Create Rendering of Mean Value at Target Layer
                int    intGCBreakeCount = Convert.ToInt32(nudGCNClasses.Value);
                string strGCRenderField = cboValueField.Text;

                IGeoFeatureLayer pGeofeatureLayer;
                if (chkNewLayer.Checked == true)
                {
                    IFeatureLayer pflOutput = new FeatureLayerClass();
                    pflOutput.FeatureClass = pFClass;
                    pflOutput.Name         = txtNewLayer.Text;
                    pflOutput.Visible      = true;

                    pGeofeatureLayer = (IGeoFeatureLayer)pflOutput;
                }
                else
                {
                    pGeofeatureLayer = (IGeoFeatureLayer)pFLayer;
                }

                ITable       pTable = (ITable)pFClass;
                IClassifyGEN pClassifyGEN;
                switch (cboGCClassify.Text)
                {
                case "Equal Interval":
                    pClassifyGEN = new EqualIntervalClass();
                    break;

                case "Geometrical Interval":
                    pClassifyGEN = new GeometricalInterval();
                    break;

                case "Natural Breaks":
                    pClassifyGEN = new NaturalBreaksClass();
                    break;

                case "Quantile":
                    pClassifyGEN = new QuantileClass();
                    break;

                case "StandardDeviation":
                    pClassifyGEN = new StandardDeviationClass();
                    break;

                default:
                    pClassifyGEN = new NaturalBreaksClass();
                    break;
                }

                //Need to be changed 1/29/15
                ITableHistogram pTableHistogram = new BasicTableHistogramClass();
                pTableHistogram.Field = strGCRenderField;
                pTableHistogram.Table = pTable;
                IBasicHistogram pHistogram = (IBasicHistogram)pTableHistogram;

                object xVals, frqs;
                pHistogram.GetHistogram(out xVals, out frqs);
                pClassifyGEN.Classify(xVals, frqs, intGCBreakeCount);

                ClassBreaksRenderer pRender = new ClassBreaksRenderer();
                double[]            cb      = (double[])pClassifyGEN.ClassBreaks;
                pRender.Field        = strGCRenderField;
                pRender.BreakCount   = intGCBreakeCount;
                pRender.MinimumBreak = cb[0];

                //' create our color ramp
                IAlgorithmicColorRamp pColorRamp = new AlgorithmicColorRampClass();
                pColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
                IRgbColor pColor1 = new RgbColor();
                IRgbColor pColor2 = new RgbColor();

                //Can Change the color in here!
                pColor1.Red   = picSymolfrom.BackColor.R;
                pColor1.Green = picSymolfrom.BackColor.G;
                pColor1.Blue  = picSymolfrom.BackColor.B;

                Boolean blnOK = true;
                pColor2.Red          = picSymbolTo.BackColor.R;
                pColor2.Green        = picSymbolTo.BackColor.G;
                pColor2.Blue         = picSymbolTo.BackColor.B;
                pColorRamp.FromColor = pColor1;
                pColorRamp.ToColor   = pColor2;
                pColorRamp.Size      = intGCBreakeCount;
                pColorRamp.CreateRamp(out blnOK);

                IEnumColors pEnumColors = pColorRamp.Colors;
                pEnumColors.Reset();

                IRgbColor pColorOutline = new RgbColor();
                //Can Change the color in here!
                pColorOutline.Red   = picGCLineColor.BackColor.R;
                pColorOutline.Green = picGCLineColor.BackColor.G;
                pColorOutline.Blue  = picGCLineColor.BackColor.B;
                double dblGCOutlineSize = Convert.ToDouble(nudGCLinewidth.Value);

                ICartographicLineSymbol pOutLines = new CartographicLineSymbol();
                pOutLines.Width = dblGCOutlineSize;
                pOutLines.Color = (IColor)pColorOutline;

                //' use this interface to set dialog properties
                IClassBreaksUIProperties pUIProperties = (IClassBreaksUIProperties)pRender;
                pUIProperties.ColorRamp = "Custom";

                ISimpleFillSymbol pSimpleFillSym;
                //' be careful, indices are different for the diff lists
                for (int j = 0; j < intGCBreakeCount; j++)
                {
                    pRender.Break[j]          = cb[j + 1];
                    pRender.Label[j]          = Math.Round(cb[j], 2).ToString() + " - " + Math.Round(cb[j + 1], 2).ToString();
                    pUIProperties.LowBreak[j] = cb[j];
                    pSimpleFillSym            = new SimpleFillSymbolClass();
                    pSimpleFillSym.Color      = pEnumColors.Next();
                    pSimpleFillSym.Outline    = pOutLines;
                    pRender.Symbol[j]         = (ISymbol)pSimpleFillSym;
                }
                pGeofeatureLayer.Renderer = (IFeatureRenderer)pRender;
                if (chkNewLayer.Checked == true)
                {
                    mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGeofeatureLayer);
                }



                ////* Uncertainty Part *////
                //Declare variables in if parts

                if (tcUncern.SelectedIndex == 0) //Graduated Color
                {
                    int    intUncernBreakCount = Convert.ToInt32(nudCoNClasses.Value);
                    string strUncerFieldName   = cboUField.Text;

                    IFeatureLayer pflUncern = new FeatureLayerClass();
                    pflUncern.FeatureClass = pFClass;
                    pflUncern.Name         = cboSourceLayer.Text + " Uncertainty";
                    pflUncern.Visible      = true;

                    IGeoFeatureLayer pGFLUncern = (IGeoFeatureLayer)pflUncern;
                    switch (cboTeClassify.Text)
                    {
                    case "Equal Interval":
                        pClassifyGEN = new EqualIntervalClass();
                        break;

                    case "Geometrical Interval":
                        pClassifyGEN = new GeometricalInterval();
                        break;

                    case "Natural Breaks":
                        pClassifyGEN = new NaturalBreaksClass();
                        break;

                    case "Quantile":
                        pClassifyGEN = new QuantileClass();
                        break;

                    case "StandardDeviation":
                        pClassifyGEN = new StandardDeviationClass();
                        break;

                    default:
                        pClassifyGEN = new NaturalBreaksClass();
                        break;
                    }
                    //Need to be changed 1/29/15
                    pTableHistogram       = new BasicTableHistogramClass();
                    pTableHistogram.Field = strUncerFieldName;
                    pTableHistogram.Table = pTable;
                    pHistogram            = (IBasicHistogram)pTableHistogram;

                    pHistogram.GetHistogram(out xVals, out frqs);
                    pClassifyGEN.Classify(xVals, frqs, intUncernBreakCount);

                    pRender              = new ClassBreaksRenderer();
                    cb                   = (double[])pClassifyGEN.ClassBreaks;
                    pRender.Field        = strUncerFieldName;
                    pRender.BreakCount   = intUncernBreakCount;
                    pRender.MinimumBreak = cb[0];

                    IClassBreaksUIProperties pUIColProperties = (IClassBreaksUIProperties)pRender;
                    pUIColProperties.ColorRamp = "Custom";

                    pColorRamp           = new AlgorithmicColorRampClass();
                    pColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
                    pColor1 = new RgbColor();
                    pColor2 = new RgbColor();

                    //Can Change the color in here!
                    pColor1 = pSnippet.getRGB(picCoColorFrom.BackColor.R, picCoColorFrom.BackColor.G, picCoColorFrom.BackColor.B);
                    pColor2 = pSnippet.getRGB(picCoColorTo.BackColor.R, picCoColorTo.BackColor.G, picCoColorTo.BackColor.B);
                    if (pColor1 == null || pColor2 == null)
                    {
                        return;
                    }

                    blnOK = true;
                    pColorRamp.FromColor = pColor1;
                    pColorRamp.ToColor   = pColor2;
                    pColorRamp.Size      = intUncernBreakCount;
                    pColorRamp.CreateRamp(out blnOK);

                    pEnumColors = pColorRamp.Colors;
                    pEnumColors.Reset();

                    pColorOutline = pSnippet.getRGB(picCoLineColor.BackColor.R, picCoLineColor.BackColor.G, picCoLineColor.BackColor.B);
                    if (pColorOutline == null)
                    {
                        return;
                    }

                    double dblCoOutlineSize = Convert.ToDouble(nudCoLinewidth.Value);

                    pOutLines       = new CartographicLineSymbol();
                    pOutLines.Width = dblCoOutlineSize;
                    pOutLines.Color = (IColor)pColorOutline;

                    //' use this interface to set dialog properties
                    pUIColProperties           = (IClassBreaksUIProperties)pRender;
                    pUIColProperties.ColorRamp = "Custom";

                    ISimpleMarkerSymbol pSimpleMarkerSym;
                    double dblCoSymSize = Convert.ToDouble(nudCoSymbolSize.Value);
                    //' be careful, indices are different for the diff lists
                    for (int j = 0; j < intUncernBreakCount; j++)
                    {
                        pRender.Break[j]              = cb[j + 1];
                        pRender.Label[j]              = Math.Round(cb[j], 2).ToString() + " - " + Math.Round(cb[j + 1], 2).ToString();
                        pUIColProperties.LowBreak[j]  = cb[j];
                        pSimpleMarkerSym              = new SimpleMarkerSymbolClass();
                        pSimpleMarkerSym.Size         = dblCoSymSize;
                        pSimpleMarkerSym.Color        = pEnumColors.Next();
                        pSimpleMarkerSym.Outline      = true;
                        pSimpleMarkerSym.OutlineColor = pColorOutline;
                        pSimpleMarkerSym.OutlineSize  = dblCoOutlineSize;
                        pRender.Symbol[j]             = (ISymbol)pSimpleMarkerSym;
                    }

                    pGFLUncern.Renderer = (IFeatureRenderer)pRender;
                    mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGFLUncern);
                }
                else if (tcUncern.SelectedIndex == 1) //Texture
                {
                    //Create Rendering of Uncertainty at Target Layer
                    int    intUncernBreakCount = Convert.ToInt32(nudTeNClasses.Value);
                    string strUncerFieldName   = cboUField.Text;

                    IFeatureLayer pflUncern = new FeatureLayerClass();
                    pflUncern.FeatureClass = pFClass;
                    pflUncern.Name         = cboSourceLayer.Text + " Uncertainty";
                    pflUncern.Visible      = true;

                    IGeoFeatureLayer pGFLUncern = (IGeoFeatureLayer)pflUncern;
                    switch (cboTeClassify.Text)
                    {
                    case "Equal Interval":
                        pClassifyGEN = new EqualIntervalClass();
                        break;

                    case "Geometrical Interval":
                        pClassifyGEN = new GeometricalInterval();
                        break;

                    case "Natural Breaks":
                        pClassifyGEN = new NaturalBreaksClass();
                        break;

                    case "Quantile":
                        pClassifyGEN = new QuantileClass();
                        break;

                    case "StandardDeviation":
                        pClassifyGEN = new StandardDeviationClass();
                        break;

                    default:
                        pClassifyGEN = new NaturalBreaksClass();
                        break;
                    }
                    //Need to be changed 1/29/15
                    pTableHistogram       = new BasicTableHistogramClass();
                    pTableHistogram.Field = strUncerFieldName;
                    pTableHistogram.Table = pTable;
                    pHistogram            = (IBasicHistogram)pTableHistogram;

                    pHistogram.GetHistogram(out xVals, out frqs);
                    pClassifyGEN.Classify(xVals, frqs, intUncernBreakCount);

                    pRender              = new ClassBreaksRenderer();
                    cb                   = (double[])pClassifyGEN.ClassBreaks;
                    pRender.Field        = strUncerFieldName;
                    pRender.BreakCount   = intUncernBreakCount;
                    pRender.MinimumBreak = cb[0];

                    IClassBreaksUIProperties pUITexProperties = (IClassBreaksUIProperties)pRender;
                    pUITexProperties.ColorRamp = "Custom";

                    ILineFillSymbol pLineFillSym    = new LineFillSymbolClass();
                    double          dblFromSep      = Convert.ToDouble(nudSeperationFrom.Value);
                    double          dblToSep        = Convert.ToDouble(nudSeperationTo.Value);
                    double          dblInstantSep   = (dblFromSep - dblToSep) / Convert.ToDouble(intUncernBreakCount - 1);
                    double          dblFromAngle    = Convert.ToDouble(nudAngleFrom.Value);
                    double          dblToAngle      = Convert.ToDouble(nudAngleFrom.Value); // Remove the angle part (04/16)
                    double          dblInstantAngle = (dblToAngle - dblFromAngle) / Convert.ToDouble(intUncernBreakCount - 1);
                    double          dblLinewidth    = Convert.ToDouble(nudTeLinewidth.Value);
                    IRgbColor       pLineColor      = new RgbColor();
                    pLineColor.Red   = picTeLineColor.BackColor.R;
                    pLineColor.Green = picTeLineColor.BackColor.G;
                    pLineColor.Blue  = picTeLineColor.BackColor.B;

                    //' be careful, indices are different for the diff lists
                    for (int j = 0; j < intUncernBreakCount; j++)
                    {
                        pRender.Break[j]             = cb[j + 1];
                        pRender.Label[j]             = Math.Round(cb[j], 5).ToString() + " - " + Math.Round(cb[j + 1], 5).ToString();
                        pUITexProperties.LowBreak[j] = cb[j];
                        pLineFillSym                  = new LineFillSymbolClass();
                        pLineFillSym.Angle            = dblFromAngle + (dblInstantAngle * Convert.ToDouble(j));
                        pLineFillSym.Color            = pLineColor;
                        pLineFillSym.Separation       = dblFromSep - (dblInstantSep * Convert.ToDouble(j));
                        pLineFillSym.LineSymbol.Width = dblLinewidth;
                        pRender.Symbol[j]             = (ISymbol)pLineFillSym;
                    }
                    pGFLUncern.Renderer = (IFeatureRenderer)pRender;
                    mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGFLUncern);
                }
                else if (tcUncern.SelectedIndex == 2) //For Proportional Symbols
                {
                    string strUncerFieldName = cboUField.Text;
                    double dblMinPtSize      = Convert.ToDouble(nudProSymbolSize.Value);
                    double dblLineWidth      = Convert.ToDouble(nudProLinewidth.Value);

                    IFeatureLayer pflUncern = new FeatureLayerClass();
                    pflUncern.FeatureClass = pFClass;
                    pflUncern.Name         = cboSourceLayer.Text + " Uncertainty";
                    pflUncern.Visible      = true;

                    //Find Fields
                    int intUncernIdx = pTable.FindField(strUncerFieldName);

                    //Find Min value
                    //Set to initial value for min
                    IField          pUncernField = pTable.Fields.get_Field(intUncernIdx);
                    ICursor         pCursor      = pTable.Search(null, false);
                    IDataStatistics pDataStat    = new DataStatisticsClass();
                    pDataStat.Field  = pUncernField.Name;
                    pDataStat.Cursor = pCursor;
                    IStatisticsResults pStatResults = pDataStat.Statistics;
                    double             dblMinValue  = pStatResults.Minimum;
                    double             dblMaxValue  = pStatResults.Maximum;
                    pCursor.Flush();


                    IRgbColor pSymbolRgb = pSnippet.getRGB(picProSymbolColor.BackColor.R, picProSymbolColor.BackColor.G, picProSymbolColor.BackColor.B);
                    if (pSymbolRgb == null)
                    {
                        return;
                    }

                    IRgbColor pLineRgb = pSnippet.getRGB(picProiLineColor.BackColor.R, picProiLineColor.BackColor.G, picProiLineColor.BackColor.B);
                    if (pLineRgb == null)
                    {
                        return;
                    }

                    ISimpleMarkerSymbol pSMarkerSym = new SimpleMarkerSymbolClass();
                    pSMarkerSym.Style        = esriSimpleMarkerStyle.esriSMSCircle;
                    pSMarkerSym.Size         = dblMinPtSize;
                    pSMarkerSym.OutlineSize  = dblLineWidth;
                    pSMarkerSym.Outline      = true;
                    pSMarkerSym.OutlineColor = (IColor)pLineRgb;
                    pSMarkerSym.Color        = (IColor)pSymbolRgb;

                    IGeoFeatureLayer            pGFLUncern    = (IGeoFeatureLayer)pflUncern;
                    IProportionalSymbolRenderer pUncernRender = new ProportionalSymbolRendererClass();
                    pUncernRender.LegendSymbolCount = 2; //Need to be changed 0219
                    pUncernRender.Field             = strUncerFieldName;
                    pUncernRender.MaxDataValue      = dblMaxValue;
                    pUncernRender.MinDataValue      = dblMinValue;
                    pUncernRender.MinSymbol         = (ISymbol)pSMarkerSym;
                    pUncernRender.ValueUnit         = esriUnits.esriUnknownUnits;
                    pUncernRender.BackgroundSymbol  = null;
                    pUncernRender.CreateLegendSymbols();

                    pGFLUncern.Renderer = (IFeatureRenderer)pUncernRender;
                    mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGFLUncern);
                }
                else if (tcUncern.SelectedIndex == 3) // Bar
                {
                    string strUncerFieldName = cboUField.Text;
                    double dblMaxLength      = Convert.ToDouble(nudMaxBarHeight.Value);
                    double dblBarWidth       = Convert.ToDouble(nudBarWidth.Value);

                    IFeatureLayer pflUncern = new FeatureLayerClass();
                    pflUncern.FeatureClass = pFClass;
                    pflUncern.Name         = cboSourceLayer.Text + " Uncertainty";
                    pflUncern.Visible      = true;

                    int             intUncernIdx = pTable.FindField(strUncerFieldName);
                    IField          pUncernField = pTable.Fields.get_Field(intUncernIdx);
                    ICursor         pCursor      = pTable.Search(null, false);
                    IDataStatistics pDataStat    = new DataStatisticsClass();
                    pDataStat.Field  = pUncernField.Name;
                    pDataStat.Cursor = pCursor;
                    IStatisticsResults pStatResults = pDataStat.Statistics;
                    double             dblMaxValue  = pStatResults.Maximum;
                    pCursor.Flush();


                    IChartRenderer  chartRenderer  = new ChartRendererClass();
                    IRendererFields rendererFields = chartRenderer as IRendererFields;
                    rendererFields.AddField(strUncerFieldName);

                    IBarChartSymbol barChartSymbol = new BarChartSymbolClass();
                    barChartSymbol.Width = dblBarWidth;
                    IMarkerSymbol markerSymbol = barChartSymbol as IMarkerSymbol;
                    markerSymbol.Size = dblMaxLength;
                    IChartSymbol chartSymbol = barChartSymbol as IChartSymbol;
                    chartSymbol.MaxValue = dblMaxValue;
                    ISymbolArray symbolArray = barChartSymbol as ISymbolArray;
                    IFillSymbol  fillSymbol  = new SimpleFillSymbolClass();
                    fillSymbol.Color = pSnippet.getRGB(picBarSymCol.BackColor.R, picBarSymCol.BackColor.G, picBarSymCol.BackColor.B);
                    if (fillSymbol.Color == null)
                    {
                        return;
                    }
                    symbolArray.AddSymbol(fillSymbol as ISymbol);

                    if (chk3D.Checked)
                    {
                        I3DChartSymbol p3DChartSymbol = barChartSymbol as I3DChartSymbol;
                        p3DChartSymbol.Display3D = true;
                        p3DChartSymbol.Thickness = 3;
                    }
                    chartRenderer.ChartSymbol = barChartSymbol as IChartSymbol;
                    SimpleFillSymbol pBaseFillSym = new SimpleFillSymbolClass();
                    //pBaseFillSym.Color = pSnippet.getRGB(picBarSymCol.BackColor.R, picBarSymCol.BackColor.G, picBarSymCol.BackColor.B);
                    //chartRenderer.BaseSymbol = pBaseFillSym as ISymbol;
                    chartRenderer.UseOverposter = false;
                    chartRenderer.CreateLegend();
                    IGeoFeatureLayer pGFLUncern = (IGeoFeatureLayer)pflUncern;
                    pGFLUncern.Renderer = (IFeatureRenderer)chartRenderer;
                    mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGFLUncern);
                }
                #region illumination
                //This function is not applied in this version. 032317 HK
                //}
                //    else if (tcUncern.SelectedIndex == 4) //illumination
                //    {
                //        frmProgress pfrmProgress = new frmProgress();
                //        pfrmProgress.lblStatus.Text = "Processing:";
                //        pfrmProgress.pgbProgress.Style = ProgressBarStyle.Marquee;
                //        pfrmProgress.Show();

                //        string strUncerFieldName = cboUField.Text;

                //        IGeoDataset geoDataset_output = createRasterfromPolygon(pFClass, strUncerFieldName, pFLayer, 100);

                //        double altitude = Convert.ToDouble(nudAltitude.Value);
                //        double azimuth = Convert.ToDouble(nudAzimuth.Value);
                //        object zFactor = Convert.ToDouble(nudZFactor.Value);


                //        ISurfaceOp2 pSurfOP = new RasterSurfaceOpClass();
                //        IRaster pOutputDS = (IRaster)pSurfOP.HillShade(geoDataset_output, azimuth, altitude, true, ref zFactor);

                //        ((IDataset)geoDataset_output).Delete();
                //        // Create a raster for viewing
                //        ESRI.ArcGIS.Carto.IRasterLayer rasterLayer = new ESRI.ArcGIS.Carto.RasterLayerClass();
                //        rasterLayer.CreateFromRaster(pOutputDS);

                //        //Calculate hillshade value at slope 0 to set as background value
                //        double dblRadian = (Math.PI / 180) * (90 - altitude);
                //        double dblBackValue = Math.Truncate(255 * Math.Cos(dblRadian));

                //        IRasterStretch pRasterStretch = new RasterStretchColorRampRendererClass();
                //        IColor pColor = new RgbColorClass();
                //        pColor.NullColor = true;
                //        pColor.Transparency = 0;
                //        pRasterStretch.Background = true;
                //        pRasterStretch.BackgroundColor = pColor;
                //        pRasterStretch.set_BackgroundValues(ref dblBackValue);

                //        rasterLayer.Name = "Uncertainty of " + strGCRenderField;
                //        rasterLayer.Renderer = pRasterStretch as IRasterRenderer;
                //        rasterLayer.Renderer.Update();

                //        //Apply Transparency
                //        ILayerEffects pLayerEffect = (ILayerEffects)rasterLayer;
                //        pLayerEffect.Transparency = Convert.ToInt16(nudTransparent.Value);

                //        pfrmProgress.Close();
                //        // Add the raster to the map
                //        pActiveView.FocusMap.AddLayer(rasterLayer);

                //    }

                //    mForm.axMapControl1.ActiveView.Refresh();
                //    mForm.axTOCControl1.Update();
                #endregion
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
Example #8
0
        /// <summary>
        /// 根据MXD模板动态设置信息后出专题图
        /// </summary>
        /// <param name="themeName">专题名称</param>
        /// <param name="layerId">图层id</param>
        public static string exportMap(int layerId, List <IGeometry> inputGeometryList)
        {
            IFeatureClass kzxFs     = Utils.featureClsArray[layerId];
            string        themeName = kzxFs.AliasName;

            string mxdPath = Utils.workSpace + Utils.name_MXD + ".mxd";

            if (!File.Exists(mxdPath))
            {
                return(null);
            }
            else
            {
                //打开当前Mxd文档
                IMapDocument mapDoc = new MapDocumentClass();
                mapDoc.Open(mxdPath, "");

                string mxdFileName = mapDoc.DocumentFilename;

                IPageLayout pageLayout = mapDoc.PageLayout;

                IMap map = mapDoc.ActiveView.FocusMap;
                //修改当前图层为可见,其他图层不可见
                for (int L = 0; L < map.LayerCount; L++)
                {
                    map.get_Layer(L).Visible = false;
                }
                //只显示第0个图层input和当前图层
                // map.get_Layer(0).Visible = true;
                map.get_Layer(layerId + 1).Visible = true;
                try
                {
                    //mapDoc.Save();
                }
                catch (System.Exception ex)
                {
                    mapDoc.Close();
                    throw ex;
                }
                IActiveView mapActiveView        = map as IActiveView;
                IActiveView pageLayoutActiveView = pageLayout as IActiveView;

                //设置图名
                //IElement tmElement = GetPageLayoutElementByName(pageLayout, "Title");
                //if (tmElement != null)
                //{
                //    ITextElement textElement = tmElement as ITextElement;

                //    textElement.Text = themeName + "检测结果图";

                //}
                //绘制输入范围的Element
                IRgbColor   pRgbColor;
                IActiveView pActiveView;


                IGraphicsContainer pGraphicsContainer = mapActiveView.FocusMap as IGraphicsContainer;; //起到容器的作用,可使画的内容不消失
                pRgbColor       = new RgbColorClass();
                pRgbColor.Red   = 255;
                pRgbColor.Green = 150;
                pRgbColor.Blue  = 0;
                IRgbColor pRgbColor2 = new RgbColorClass();
                pRgbColor2.Red   = 255;
                pRgbColor2.Green = 0;
                pRgbColor2.Blue  = 0;

                pActiveView = mapActiveView;
                ILineFillSymbol pLineFillSymbol = new LineFillSymbolClass();
                pLineFillSymbol.LineSymbol.Color = pRgbColor;
                pLineFillSymbol.Color            = pRgbColor;
                pLineFillSymbol.Angle            = 45;
                pLineFillSymbol.Separation       = 20;
                pLineFillSymbol.Outline.Width    = 10;
                pLineFillSymbol.Outline.Color    = pRgbColor2;

                // 多边形符号
                ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbol();
                pSimpleFillSymbol.Color         = pRgbColor;
                pSimpleFillSymbol.Style         = esriSimpleFillStyle.esriSFSNull;
                pSimpleFillSymbol.Outline.Width = 10;
                pSimpleFillSymbol.Outline.Color = pRgbColor2;


                // 线符号
                ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbol();
                pSimpleLineSymbol.Color    = pRgbColor2;
                pSimpleLineSymbol.Style    = esriSimpleLineStyle.esriSLSSolid;
                pSimpleLineSymbol.Width    = 10;
                pLineFillSymbol.LineSymbol = pSimpleLineSymbol;


                foreach (IGeometry pgeo in inputGeometryList)
                {
                    // 绘制多边形元素
                    IElement pElement = new PolygonElement();
                    pElement.Geometry = pgeo;
                    //pFillShapeElement.Symbol.Outline = pSimpleLineSymbol as ILineSymbol;
                    IFillShapeElement pFillShapeElement = pElement as IFillShapeElement;
                    pFillShapeElement.Symbol = (IFillSymbol)CreateSimpleFillSymbol(Color.Red, 1, esriSimpleFillStyle.esriSFSDiagonalCross);

                    pGraphicsContainer.AddElement(pElement as IElement, 0);
                }
                pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

                mapActiveView.Extent = Utils.pfwEnv;

                Guid   guid     = Guid.NewGuid();
                string fileName = guid.ToString().Replace("-", "_");

                string tempImage = Utils.workSpace + @"wordFiles\" + themeName + "检测结果图" + fileName + ".png";

                ExportRasterFile(pageLayoutActiveView, tempImage, "PNG", 140);
                mapDoc.Close();

                return(tempImage);
            }
        }