示例#1
0
        private void cboSourceLayer_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                clsSnippet pSnippet     = new clsSnippet();
                string     strLayerName = cboSourceLayer.Text;

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

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

                IFields fields = pFClass.Fields;

                CboUField.Items.Clear();
                CboUField.Text = "";

                for (int i = 0; i < fields.FieldCount; i++)
                {
                    CboUField.Items.Add(fields.get_Field(i).Name);
                }
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
示例#2
0
        private void cboTargetLayer_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string strLayerName = cboTargetLayer.Text;

                int    intLIndex = m_pSnippet.GetIndexNumberFromLayerName(m_pActiveView, strLayerName);
                ILayer pLayer    = m_pForm.axMapControl1.get_Layer(intLIndex);

                m_pFLayer = pLayer as IFeatureLayer;
                m_pFClass = m_pFLayer.FeatureClass;

                IFields fields = m_pFClass.Fields;

                cboFieldName.Items.Clear();
                cboFieldName.Text = "";
                for (int i = 0; i < fields.FieldCount; i++)
                {
                    if (m_pSnippet.FindNumberFieldType(fields.get_Field(i)))
                    {
                        cboFieldName.Items.Add(fields.get_Field(i).Name);
                    }
                }

                //New Spatial Weight matrix function 080317
                clsSnippet.SpatialWeightMatrixType pSWMType = new clsSnippet.SpatialWeightMatrixType();
                if (m_pFClass.ShapeType == esriGeometryType.esriGeometryPolygon) //Apply Different Spatial weight matrix according to geometry type 07052017 HK
                {
                    //txtSWM.Text = pSWMType.strPolySWM;
                    txtSWM.DataSource = pSWMType.strPolyDefs;

                    lblClip.Visible     = false; btnSubset.Visible = false; btnSubset.Enabled = false;
                    chkCumulate.Visible = true; chkCumulate.Text = "Cumulate neighbors:";
                    lblAdvanced.Text    = "Contiguity Order:";
                    nudAdvanced.Value   = 1; nudAdvanced.Increment = 1; nudAdvanced.DecimalPlaces = 0;
                }
                else if (m_pFClass.ShapeType == esriGeometryType.esriGeometryPoint)
                {
                    //txtSWM.Text = pSWMType.strPointSWM;
                    txtSWM.DataSource   = pSWMType.strPointDef;
                    lblClip.Visible     = true; btnSubset.Visible = true; btnSubset.Enabled = true;
                    chkCumulate.Visible = false;
                    lblAdvanced.Text    = "Threshold distance:";
                    nudAdvanced.Value   = 100; nudAdvanced.Increment = 10; nudAdvanced.DecimalPlaces = 2;
                }
                else if (m_pFClass.ShapeType == esriGeometryType.esriGeometryPolyline)
                {
                    MessageBox.Show("Spatial weights matrix for polyline is not supported.");
                    btnSubset.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
示例#3
0
        private void cboTargetLayer_SelectedIndexChanged(object sender, EventArgs e)
        {
            string strLayerName = cboTargetLayer.Text;

            int    intLIndex = m_pSnippet.GetIndexNumberFromLayerName(m_pActiveView, strLayerName);
            ILayer pLayer    = m_pForm.axMapControl1.get_Layer(intLIndex);

            m_pFLayer = pLayer as IFeatureLayer;
        }
示例#4
0
        private void cboTargetLayer_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string strLayerName = cboTargetLayer.Text;

                int    intLIndex = m_pSnippet.GetIndexNumberFromLayerName(m_pActiveView, strLayerName);
                ILayer pLayer    = m_pForm.axMapControl1.get_Layer(intLIndex);

                IFeatureLayer pFLayer = pLayer as IFeatureLayer;
                m_pFClass = pFLayer.FeatureClass;

                clsSnippet.SpatialWeightMatrixType pSWMType = new clsSnippet.SpatialWeightMatrixType();
                if (m_pFClass.ShapeType == esriGeometryType.esriGeometryPolygon) //Apply Different Spatial weight matrix according to geometry type 07052017 HK
                {
                    txtSWM.Text = pSWMType.strPolySWM;
                }
                else if (m_pFClass.ShapeType == esriGeometryType.esriGeometryPoint)
                {
                    txtSWM.Text = pSWMType.strPointSWM;
                }
                else if (m_pFClass.ShapeType == esriGeometryType.esriGeometryPolyline)
                {
                    MessageBox.Show("Spatial weight matrix for polyline is not supported.");
                }

                IFields fields = m_pFClass.Fields;

                cboFieldName.Items.Clear();

                for (int i = 0; i < fields.FieldCount; i++)
                {
                    if (m_pSnippet.FindNumberFieldType(fields.get_Field(i)))
                    {
                        cboFieldName.Items.Add(fields.get_Field(i).Name);
                    }
                }
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
示例#5
0
        private void cboTargetLayer_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string strLayerName = cboTargetLayer.Text;

                int    intLIndex = m_pSnippet.GetIndexNumberFromLayerName(m_pActiveView, strLayerName);
                ILayer pLayer    = m_pForm.axMapControl1.get_Layer(intLIndex);

                m_pFLayer = pLayer as IFeatureLayer;
                double dblHeight = m_pFLayer.AreaOfInterest.Height;
                double dblWidth  = m_pFLayer.AreaOfInterest.Width;

                if (cboStudyArea.Text == "Minimum Enclosing Rectangle")
                {
                    m_dblArea = dblHeight * dblWidth;
                }

                double dblShortLine = 0;
                if (dblHeight > dblWidth)
                {
                    dblShortLine       = dblWidth;
                    nudDistInc.Maximum = Convert.ToDecimal(dblHeight);
                }
                else
                {
                    dblShortLine       = dblHeight;
                    nudDistInc.Maximum = Convert.ToDecimal(dblWidth);
                }

                double dblNdigits = Math.Pow(10, Math.Ceiling(Math.Log10(dblShortLine)));

                double dblValue = Math.Round(dblShortLine / 4 / dblNdigits, 1) * (dblNdigits / 10);
                nudDistInc.Value = Convert.ToDecimal(dblValue);

                m_pFClass = m_pFLayer.FeatureClass;
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
示例#6
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                string strLayerName = cboLayer.Text;
                string strFieldType = cboType.Text;
                string strFieldName = txtName.Text;

                if (strLayerName == "" || strFieldType == "" || strFieldName == "")
                {
                    MessageBox.Show("Please select variables");
                }

                clsBlockNames pBlockNames = new clsBlockNames();
                if (pBlockNames.BlockPreDeterminedName(strFieldName))
                {
                    return;
                }

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

                IFeatureLayer pFLayer   = pLayer as IFeatureLayer;
                IFeatureClass pFClass   = pFLayer.FeatureClass;
                int           intFldIdx = pFClass.FindField(strFieldName);
                if (intFldIdx != -1)
                {
                    MessageBox.Show("The field name is already assigned.");
                    return;
                }

                AddField(pFClass, strFieldName, strFieldType);
                MessageBox.Show("Done");

                if (intHandle != IntPtr.Zero)
                {
                    frmAttributeTable pfrmAttributeTable = pSnippet.returnAttTable(intHandle);
                    if (pfrmAttributeTable == null)
                    {
                        return;
                    }
                    pSnippet.LoadingAttributeTable(pLayer, pfrmAttributeTable);
                }

                this.Close();
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
示例#7
0
        private void cboTargetLayer_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string strLayerName = cboTargetLayer.Text;

                int    intLIndex = m_pSnippet.GetIndexNumberFromLayerName(m_pActiveView, strLayerName);
                ILayer pLayer    = m_pForm.axMapControl1.get_Layer(intLIndex);

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

                IFields fields = pFClass.Fields;

                cboFldnm1.Text = "";
                cboFldnm2.Text = "";

                cboFldnm1.Items.Clear();
                cboFldnm2.Items.Clear();

                for (int i = 0; i < fields.FieldCount; i++)
                {
                    if (m_pSnippet.FindNumberFieldType(fields.get_Field(i)))
                    {
                        cboFldnm1.Items.Add(fields.get_Field(i).Name);
                        cboFldnm2.Items.Add(fields.get_Field(i).Name);
                    }
                }

                UpdateListview(lvFields, pFClass);
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
示例#8
0
        private void cboTargetLayer_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string strLayerName = cboTargetLayer.Text;

                int    intLIndex = m_pSnippet.GetIndexNumberFromLayerName(m_pActiveView, strLayerName);
                ILayer pLayer    = m_pForm.axMapControl1.get_Layer(intLIndex);

                IFeatureLayer pFLayer = pLayer as IFeatureLayer;
                ESRI.ArcGIS.Geodatabase.IFeatureClass pFClass = pFLayer.FeatureClass;

                IFields fields = pFClass.Fields;

                cboFieldName.Items.Clear();
                cboGroupField.Items.Clear();
                cboGroupField.Items.Add("None");

                for (int i = 0; i < fields.FieldCount; i++)
                {
                    if (fields.get_Field(i).Type == esriFieldType.esriFieldTypeString)
                    {
                        cboGroupField.Items.Add(fields.get_Field(i).Name);
                    }
                    else
                    {
                        cboFieldName.Items.Add(fields.get_Field(i).Name);
                    }
                }
            }
            catch
            {
                MessageBox.Show("Error 222");
                return;
            }
        }
示例#9
0
        private void cboTargetLayer_SelectedIndexChanged(object sender, EventArgs e)
        {
            //try
            //{
            string strLayerName = cboTargetLayer.Text;

            int    intLIndex = m_pSnippet.GetIndexNumberFromLayerName(m_pActiveView, strLayerName);
            ILayer pLayer    = m_pForm.axMapControl1.get_Layer(intLIndex);

            m_pFLayer = pLayer as IFeatureLayer;
            m_pFClass = m_pFLayer.FeatureClass;


            IFields fields = m_pFClass.Fields;


            List <string> lstFieldname = new List <string>();


            while (dgvVariables.Rows.Count > 1)
            {
                dgvVariables.Rows.RemoveAt(0);
            }


            for (int i = 0; i < fields.FieldCount; i++)
            {
                if (m_pSnippet.FindNumberFieldType(fields.get_Field(i)))
                {
                    lstFieldname.Add(fields.get_Field(i).Name);
                }
            }
            m_strFieldName = lstFieldname.ToArray();
            DataGridViewComboBoxColumn pVarColumn = (DataGridViewComboBoxColumn)dgvVariables.Columns[0];

            pVarColumn.Items.AddRange(m_strFieldName);

            DataGridViewComboBoxColumn pErrorColumn = (DataGridViewComboBoxColumn)dgvVariables.Columns[1];

            pErrorColumn.Items.AddRange(m_strFieldName);

            //}
            //catch (Exception ex)
            //{
            //    frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
            //    return;
            //}
        }
示例#10
0
        private void cboTargetLayer_SelectedIndexChanged(object sender, EventArgs e)
        {
            string strLayerName = cboTargetLayer.Text;

            int    intLIndex = m_pSnippet.GetIndexNumberFromLayerName(m_pActiveView, strLayerName);
            ILayer pLayer    = m_pForm.axMapControl1.get_Layer(intLIndex);

            m_pFLayer = pLayer as IFeatureLayer;
            double dblHeight = m_pFLayer.AreaOfInterest.Height;
            double dblWidth  = m_pFLayer.AreaOfInterest.Width;

            double dblShortLine = 0;

            if (dblHeight > dblWidth)
            {
                dblShortLine       = dblWidth;
                nudDistInc.Maximum = Convert.ToDecimal(dblHeight);
            }
            else
            {
                dblShortLine       = dblHeight;
                nudDistInc.Maximum = Convert.ToDecimal(dblWidth);
            }

            //double dblNdigits = Math.Pow(10, Math.Ceiling(Math.Log10(dblShortLine)));
            double dblNdigits = Math.Pow(10, Math.Ceiling(Math.Log10(dblShortLine / 2)));

            double dblValue = Math.Round(dblShortLine / 2 / dblNdigits, 1) * (dblNdigits / 10);

            nudDistInc.Value = Convert.ToDecimal(dblValue);

            m_pFClass = m_pFLayer.FeatureClass;

            IFields fields = m_pFClass.Fields;

            cboValueFld.Items.Clear();

            for (int i = 0; i < fields.FieldCount; i++)
            {
                if (m_pSnippet.FindNumberFieldType(fields.get_Field(i)))
                {
                    cboValueFld.Items.Add(fields.get_Field(i).Name);
                }
            }
        }
示例#11
0
        private void cboTargetLayer_SelectedIndexChanged(object sender, EventArgs e)
        {
            clsSnippet pSnippet     = new clsSnippet();
            string     strLayerName = cboTargetLayer.Text;

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

            IFeatureLayer pFLayer = pLayer as IFeatureLayer;

            ESRI.ArcGIS.Geodatabase.IFeatureClass pFClass = pFLayer.FeatureClass;

            IFields fields = pFClass.Fields;

            cboXField.Items.Clear();
            cboYField.Items.Clear();

            for (int i = 0; i < fields.FieldCount; i++)
            {
                cboXField.Items.Add(fields.get_Field(i).Name);
                cboYField.Items.Add(fields.get_Field(i).Name);
            }
        }
示例#12
0
        private void DrawLegend()
        {
            try
            {
                if (blnBoxplot == true && cboSourceLayer.Text != "" && cboUField.Text != "" && cboValueField.Text != "")
                {
                    mForm = System.Windows.Forms.Application.OpenForms["MainForm"] as MainForm;
                    IActiveView pActiveView        = mForm.axMapControl1.ActiveView;
                    string      strTargetLayerName = cboSourceLayer.Text;
                    string      strValueField      = cboValueField.Text;
                    string      strUncerField      = cboUField.Text;

                    clsSnippet pSnippet = new clsSnippet();

                    int intTLayerIdx = pSnippet.GetIndexNumberFromLayerName(pActiveView, strTargetLayerName);

                    ILayer        pLayer  = mForm.axMapControl1.get_Layer(intTLayerIdx);
                    IFeatureLayer pFLayer = (IFeatureLayer)pLayer;

                    IFeatureClass pFeatureClass = pFLayer.FeatureClass;

                    int intValueFldIdx = pFeatureClass.FindField(strValueField);
                    int intUncerFldIdx = pFeatureClass.FindField(strUncerField);

                    REngine pEngine = mForm.pEngine;

                    pEngine.Evaluate("confLevel <- " + nudConfiLevel.Value.ToString());
                    pEngine.Evaluate("bothlevel <- 1-((100-confLevel)/200)");
                    dblError = pEngine.Evaluate("error <- qnorm(bothlevel)").AsNumeric().First();

                    //Cacluate Max value based on the confidence intervals
                    ICursor pCursor = (ICursor)pFeatureClass.Search(null, false);

                    IRow pRow = pCursor.NextRow();
                    dblMaxValue = 0;
                    double dblTempValue = 0;
                    dblMaxEstimate = 0;
                    dblMaxUncern   = 0;
                    double dblTempEstimate = 0;
                    double dblTempUncern   = 0;

                    while (pRow != null)
                    {
                        dblTempEstimate = Convert.ToDouble(pRow.get_Value(intValueFldIdx));
                        dblTempUncern   = Convert.ToDouble(pRow.get_Value(intUncerFldIdx)) * dblError;
                        dblTempValue    = dblTempEstimate + dblTempUncern;

                        if (dblTempValue > dblMaxValue)
                        {
                            dblMaxValue    = dblTempValue;
                            dblMaxEstimate = dblTempEstimate;
                            dblMaxUncern   = dblTempUncern;
                        }
                        pRow = pCursor.NextRow();
                    }
                    pCursor.Flush();


                    if (pGeofeatureLayer == null)
                    {
                        pGeofeatureLayer = null;
                        IFeatureLayer pflOutput = new FeatureLayerClass();
                        pflOutput.FeatureClass = pFeatureClass;
                        strOutputGFLName       = pFeatureClass.AliasName + "_Uncern";
                        pflOutput.Name         = strOutputGFLName;
                        pflOutput.Visible      = true;
                        pGeofeatureLayer       = (IGeoFeatureLayer)pflOutput;

                        StackedLegned pStackedLegend = new StackedLegned();
                        pStackedLegend.m_strOriRenderField    = strValueField;
                        pStackedLegend.m_strUncernRenderField = strUncerField;
                        pStackedLegend.dblMaxValue            = dblMaxValue;
                        pStackedLegend.dblMaxEstimate         = dblMaxEstimate;
                        pStackedLegend.dblMaxUncern           = dblMaxUncern;
                        pStackedLegend.bln3Dfeature           = bln3Dfeature;
                        pStackedLegend.CreateLegend();
                        pStackedLegend.PrepareFilter(pFeatureClass, null);
                        pGeofeatureLayer.Renderer = pStackedLegend;

                        pActiveView.FocusMap.AddLayer(pGeofeatureLayer);
                    }
                    else
                    {
                        int    intLIndex = pSnippet.GetIndexNumberFromLayerName(pActiveView, strOutputGFLName);
                        ILayer pNewLayer = mForm.axMapControl1.get_Layer(intLIndex);

                        IFeatureLayer pNewFLayer = pNewLayer as IFeatureLayer;
                        pGeofeatureLayer = pNewFLayer as IGeoFeatureLayer;

                        StackedLegned pStackedLegend = new StackedLegned();
                        pStackedLegend.m_strOriRenderField    = strValueField;
                        pStackedLegend.m_strUncernRenderField = strUncerField;
                        pStackedLegend.dblMaxValue            = dblMaxValue;
                        pStackedLegend.dblMaxEstimate         = dblMaxEstimate;
                        pStackedLegend.dblMaxUncern           = dblMaxUncern;
                        pStackedLegend.bln3Dfeature           = bln3Dfeature;
                        pStackedLegend.CreateLegend();
                        //pStackedLegend.PrepareFilter(pFeatureClass, null);
                        pGeofeatureLayer.Renderer = pStackedLegend;

                        //int intLIndex = pSnippet.GetIndexNumberFromLayerName(pActiveView, strOutputGFLName);
                        //ILayer pNewLayer = mForm.axMapControl1.get_Layer(intLIndex);

                        //IFeatureLayer pNewFLayer = pNewLayer as IFeatureLayer;
                        pNewFLayer = (IFeatureLayer)pGeofeatureLayer;
                    }

                    pActiveView.Refresh();
                }
                else
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
示例#13
0
        private void btnApply_Click(object sender, EventArgs e)
        {
            try
            {
                //Declare variables
                clsSnippet pSnippet     = new clsSnippet();
                string     strLayerName = cboSourceLayer.Text;

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

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

                string strOriRenderField    = cboValueField.Text;
                string strUncernRenderField = CboUField.Text;
                string strConLevelField     = nudConfidenceLevel.Value.ToString();

                if (strOriRenderField == "" || strUncernRenderField == "")
                {
                    MessageBox.Show("Plese choose field names");
                    return;
                }

                //Find Fields
                ITable pTable       = (ITable)pFClass;
                int    intOriIdx    = pTable.FindField(strOriRenderField);
                int    intUncernIdx = pTable.FindField(strUncernRenderField);

                //Create Geofeature Layer
                IGeoFeatureLayer pGeofeatureLayer = null;
                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;
                }

                //Calculate confidence levels
                Chart  pChart         = new Chart();
                double dblConInstance = pChart.DataManipulator.Statistics.InverseNormalDistribution(Convert.ToDouble(nudConfidenceLevel.Value) / 100);


                if (tcUncer.SelectedIndex == 0) //Proportional symbol composite layers
                {
                    double dblMinPtSize = Convert.ToDouble(nudSymbolSize.Value);

                    //Find max value at attribute to set to initial value for finding Min value at composite symbols
                    IField          pOriField = pTable.Fields.get_Field(intOriIdx);
                    ICursor         pCursor   = pTable.Search(null, false);
                    IDataStatistics pDataStat = new DataStatisticsClass();
                    pDataStat.Field  = pOriField.Name;
                    pDataStat.Cursor = pCursor;
                    IStatisticsResults pStatResults = pDataStat.Statistics;

                    double dblMinValue = pStatResults.Maximum;
                    pCursor.Flush();

                    pCursor = pTable.Search(null, false);
                    IRow   pRow     = pCursor.NextRow();
                    double dblValue = 0;

                    //Cacluate Min and Max value based on the confidence intervals
                    //Min
                    while (pRow != null)
                    {
                        dblValue = Convert.ToDouble(pRow.get_Value(intOriIdx)) - (Convert.ToDouble(pRow.get_Value(intUncernIdx)) * dblConInstance);
                        if (dblValue < dblMinValue)
                        {
                            dblMinValue = dblValue;
                        }
                        pRow = pCursor.NextRow();
                    }

                    //Max
                    pCursor.Flush();

                    double dblMaxValue = 0;
                    pCursor  = pTable.Search(null, false);
                    pRow     = pCursor.NextRow();
                    dblValue = 0;

                    //Cacluate Min and Max value based on the confidence intervals
                    while (pRow != null)
                    {
                        dblValue = Convert.ToDouble(pRow.get_Value(intOriIdx)) + (Convert.ToDouble(pRow.get_Value(intUncernIdx)) * dblConInstance);
                        if (dblValue > dblMaxValue)
                        {
                            dblMaxValue = dblValue;
                        }
                        pRow = pCursor.NextRow();
                    }


                    //To adjust min value to 1, if the min value is zero
                    double dbladjuctMinvalue = 0;
                    if (dblMinValue <= 0)
                    {
                        dbladjuctMinvalue = (0 - dblMinValue) + 1;
                        dblMinValue       = dblMinValue + dbladjuctMinvalue;
                    }


                    //Loading uncertainty proportional symbol renderer
                    IDisplay pDisplay = pActiveView.ScreenDisplay;

                    UncernVis.BivariateRenderer.IPropCompositeRenderer pUnProprotional = new UncernVis.BivariateRenderer.PropCompositeRenderer();

                    pUnProprotional.m_dblMinPtSize = dblMinPtSize;
                    pUnProprotional.m_dblMinValue  = dblMinValue;
                    pUnProprotional.m_dblMaxValue  = dblMaxValue;

                    pUnProprotional.m_dblOutlineSize      = Convert.ToDouble(nudLinewidth.Value);
                    pUnProprotional.m_dblAdjustedMinValue = dbladjuctMinvalue;

                    IRgbColor pSymbolRgb = new RgbColorClass();
                    pSymbolRgb.Red   = picSymbolColor.BackColor.R;
                    pSymbolRgb.Green = picSymbolColor.BackColor.G;
                    pSymbolRgb.Blue  = picSymbolColor.BackColor.B;

                    IRgbColor pLineRgb = new RgbColorClass();
                    pLineRgb.Red   = picLineColor.BackColor.R;
                    pLineRgb.Green = picLineColor.BackColor.G;
                    pLineRgb.Blue  = picLineColor.BackColor.B;

                    pUnProprotional.m_pLineRgb   = pLineRgb;
                    pUnProprotional.m_pSymbolRgb = pSymbolRgb;

                    pUnProprotional.m_strUncernRenderField = strUncernRenderField;
                    pUnProprotional.m_strOriRenderField    = strOriRenderField;

                    pUnProprotional.m_dblConInstance = dblConInstance;
                    pUnProprotional.m_pGeometryTypes = pFClass.ShapeType;

                    //Create Legend
                    pUnProprotional.CreateLegend();

                    pGeofeatureLayer.Renderer = (IFeatureRenderer)pUnProprotional;


                    if (chkNewLayer.Checked == true)
                    {
                        mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGeofeatureLayer);
                    }
                    else
                    {
                        pFLayer = (IFeatureLayer)pGeofeatureLayer;
                    }
                }
                else if (tcUncer.SelectedIndex == 1) // Chart composite symbols
                {
                    double dblChartWidth = Convert.ToDouble(nudChartWidth.Value);
                    double dblChartSize  = Convert.ToDouble(nudChartSize.Value);
                    double dblThickness  = Convert.ToDouble(nudThickness.Value);

                    //Cacluate Max value based on the confidence intervals
                    ICursor pCursor = (ICursor)pFClass.Search(null, false);

                    IRow   pRow            = pCursor.NextRow();
                    double dblMaxValue     = 0;
                    double dblTempValue    = 0;
                    double dblMaxEstimate  = 0;
                    double dblMaxUncern    = 0;
                    double dblTempEstimate = 0;
                    double dblTempUncern   = 0;

                    while (pRow != null)
                    {
                        dblTempEstimate = Convert.ToDouble(pRow.get_Value(intOriIdx));
                        dblTempUncern   = Convert.ToDouble(pRow.get_Value(intUncernIdx)) * dblConInstance;
                        dblTempValue    = dblTempEstimate + dblTempUncern;

                        if (dblTempValue > dblMaxValue)
                        {
                            dblMaxValue    = dblTempValue;
                            dblMaxEstimate = dblTempEstimate;
                            dblMaxUncern   = dblTempUncern;
                        }
                        pRow = pCursor.NextRow();
                    }
                    pCursor.Flush();


                    //IFeatureCursor pFCursor = pGeofeatureLayer.Search(null, true);

                    IChartCompositeRenderer pChartCompositeRenderer = new ChartCompositeRenderer();

                    pChartCompositeRenderer.m_dblConInstance = dblConInstance;

                    pChartCompositeRenderer.m_dblMaxValue          = dblMaxValue;
                    pChartCompositeRenderer.m_bln3Dfeature         = chk3D.Checked;
                    pChartCompositeRenderer.m_strOriRenderField    = strOriRenderField;
                    pChartCompositeRenderer.m_strUncernRenderField = strUncernRenderField;

                    pChartCompositeRenderer.m_dblMaxEstimate = dblMaxEstimate;
                    pChartCompositeRenderer.m_dblMaxUncern   = dblMaxUncern;

                    pChartCompositeRenderer.m_dblBarWidth  = dblChartWidth;
                    pChartCompositeRenderer.m_dblBarSize   = dblChartSize;
                    pChartCompositeRenderer.m_dblThickness = dblThickness;

                    pChartCompositeRenderer.CreateLegend();
                    pGeofeatureLayer.Renderer = pChartCompositeRenderer as IFeatureRenderer;
                    if (chkNewLayer.Checked == true)
                    {
                        mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGeofeatureLayer);
                    }
                    else
                    {
                        pFLayer = (IFeatureLayer)pGeofeatureLayer;
                    }
                }
                else if (tcUncer.SelectedIndex == 2) //For Line Symbol
                {
                    double dblMinPtSize = Convert.ToDouble(nudMinWidth.Value);

                    //Find max value at attribute to set to initial value for finding Min value at composite symbols
                    IField          pOriField = pTable.Fields.get_Field(intOriIdx);
                    ICursor         pCursor   = pTable.Search(null, false);
                    IDataStatistics pDataStat = new DataStatisticsClass();
                    pDataStat.Field  = pOriField.Name;
                    pDataStat.Cursor = pCursor;
                    IStatisticsResults pStatResults = pDataStat.Statistics;

                    double dblMinValue = pStatResults.Maximum;
                    pCursor.Flush();

                    pCursor = pTable.Search(null, false);
                    IRow   pRow     = pCursor.NextRow();
                    double dblValue = 0;

                    //Cacluate Min and Max value based on the confidence intervals
                    //Min
                    while (pRow != null)
                    {
                        dblValue = Convert.ToDouble(pRow.get_Value(intOriIdx)) - (Convert.ToDouble(pRow.get_Value(intUncernIdx)) * dblConInstance);
                        if (dblValue < dblMinValue)
                        {
                            dblMinValue = dblValue;
                        }
                        pRow = pCursor.NextRow();
                    }

                    //Max
                    pCursor.Flush();

                    double dblMaxValue = 0;
                    pCursor  = pTable.Search(null, false);
                    pRow     = pCursor.NextRow();
                    dblValue = 0;

                    //Cacluate Min and Max value based on the confidence intervals
                    while (pRow != null)
                    {
                        dblValue = Convert.ToDouble(pRow.get_Value(intOriIdx)) + (Convert.ToDouble(pRow.get_Value(intUncernIdx)) * dblConInstance);
                        if (dblValue > dblMaxValue)
                        {
                            dblMaxValue = dblValue;
                        }
                        pRow = pCursor.NextRow();
                    }


                    //To adjust min value to 1, if the min value is zero
                    double dbladjuctMinvalue = 0;
                    if (dblMinValue <= 0)
                    {
                        dbladjuctMinvalue = (0 - dblMinValue) + 1;
                        dblMinValue       = dblMinValue + dbladjuctMinvalue;
                    }


                    //Loading uncertainty proportional symbol renderer
                    IDisplay pDisplay = pActiveView.ScreenDisplay;

                    UncernVis.BivariateRenderer.IPropCompositeRenderer pUnProprotional = new UncernVis.BivariateRenderer.PropCompositeRenderer();

                    pUnProprotional.m_dblMinPtSize = dblMinPtSize;
                    pUnProprotional.m_dblMinValue  = dblMinValue;
                    pUnProprotional.m_dblMaxValue  = dblMaxValue;

                    pUnProprotional.m_dblOutlineSize      = 0;
                    pUnProprotional.m_dblAdjustedMinValue = dbladjuctMinvalue;

                    IRgbColor pSymbolRgb = pSnippet.getRGB(picLineConColor.BackColor.R, picLineConColor.BackColor.G, picLineConColor.BackColor.B);
                    //pSymbolRgb.Red = picSymbolColor.BackColor.R;
                    //pSymbolRgb.Green = picSymbolColor.BackColor.G;
                    //pSymbolRgb.Blue = picSymbolColor.BackColor.B;

                    IRgbColor pLineRgb = pSnippet.getRGB(picLineCntColor.BackColor.R, picLineCntColor.BackColor.G, picLineCntColor.BackColor.B);
                    //pLineRgb.Red = picLineColor.BackColor.R;
                    //pLineRgb.Green = picLineColor.BackColor.G;
                    //pLineRgb.Blue = picLineColor.BackColor.B;

                    pUnProprotional.m_pLineRgb   = pLineRgb;
                    pUnProprotional.m_pSymbolRgb = pSymbolRgb;

                    pUnProprotional.m_strUncernRenderField = strUncernRenderField;
                    pUnProprotional.m_strOriRenderField    = strOriRenderField;

                    pUnProprotional.m_dblConInstance = dblConInstance;
                    pUnProprotional.m_pGeometryTypes = pFClass.ShapeType;

                    //Create Legend
                    pUnProprotional.CreateLegend();

                    pGeofeatureLayer.Renderer = (IFeatureRenderer)pUnProprotional;


                    if (chkNewLayer.Checked == true)
                    {
                        mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGeofeatureLayer);
                    }
                    else
                    {
                        pFLayer = (IFeatureLayer)pGeofeatureLayer;
                    }
                }

                mForm.axMapControl1.ActiveView.Refresh();
                mForm.axTOCControl1.Update();
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
示例#14
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            try
            {
                if (pfrmAttributeField.cboSourceLayer.Text != "" && pfrmAttributeField.cboValueField.Text != "")
                {
                    mForm = System.Windows.Forms.Application.OpenForms["MainForm"] as MainForm;

                    IActiveView pActiveView        = mForm.axMapControl1.ActiveView;
                    string      strTargetLayerName = pfrmAttributeField.cboSourceLayer.Text;
                    string      strValueField      = pfrmAttributeField.cboValueField.Text;

                    int    x      = X;
                    int    y      = Y;
                    IPoint pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);


                    double    Tol      = 4; //Needs to be changed
                    IEnvelope pEnvelop = pPoint.Envelope;
                    pEnvelop.Expand(Tol, Tol, false);
                    ISpatialFilter pSpatialFilter = new SpatialFilterClass();
                    pSpatialFilter.Geometry   = pEnvelop;
                    pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                    clsSnippet pSnippet = new clsSnippet();

                    int intTLayerIdx = pSnippet.GetIndexNumberFromLayerName(pActiveView, strTargetLayerName);

                    ILayer        pLayer         = mForm.axMapControl1.get_Layer(intTLayerIdx);
                    IFeatureLayer pFLayer        = (IFeatureLayer)pLayer;
                    string        ShapeFieldName = pFLayer.FeatureClass.ShapeFieldName;
                    pSpatialFilter.GeometryField = pFLayer.FeatureClass.ShapeFieldName;
                    IFeatureClass  pFeatureClass = pFLayer.FeatureClass;
                    IFeatureCursor pFCursor      = pFeatureClass.Search(pSpatialFilter, false);
                    IFeature       pFeature      = pFCursor.NextFeature();
                    pFCursor.Flush();
                    if (pFeature == null)
                    {
                        return;
                    }

                    int intValueFldIdx = pFeatureClass.FindField(strValueField);

                    double[] dblAllValue = pfrmAttributeField.arrValue;
                    double[] dblValue    = new double[1];
                    dblValue[0] = Convert.ToDouble(pFeature.get_Value(intValueFldIdx));
                    int           intCount    = pFeatureClass.FeatureCount(null);
                    REngine       pEngine     = mForm.pEngine;
                    NumericVector vecValue    = pEngine.CreateNumericVector(dblValue);
                    NumericVector vecAllValue = pEngine.CreateNumericVector(dblAllValue);
                    pEngine.SetSymbol("value", vecValue);
                    pEngine.SetSymbol("all.value", vecAllValue);

                    StringBuilder sbCommand = new StringBuilder();
                    sbCommand.Append("hist(all.value);");
                    sbCommand.Append("abline(v=value, col='red');");
                    string strTitle = "Histogram";

                    pSnippet.drawPlottoForm(strTitle, sbCommand.ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("HistTool Error:" + ex.Message);
                return;
            }
        }
示例#15
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (pDrawDenplot.cboSourceLayer.Text != "" && pDrawDenplot.cboUField.Text != "" && pDrawDenplot.cboValueField.Text != "")
            {
                mForm = System.Windows.Forms.Application.OpenForms["MainForm"] as MainForm;

                IActiveView pActiveView        = mForm.axMapControl1.ActiveView;
                string      strTargetLayerName = pDrawDenplot.cboSourceLayer.Text;
                string      strValueField      = pDrawDenplot.cboValueField.Text;
                string      strUncerField      = pDrawDenplot.cboUField.Text;


                int    x      = X;
                int    y      = Y;
                IPoint pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);


                double    Tol      = 4; //Needs to be changed
                IEnvelope pEnvelop = pPoint.Envelope;
                pEnvelop.Expand(Tol, Tol, false);
                ISpatialFilter pSpatialFilter = new SpatialFilterClass();
                pSpatialFilter.Geometry   = pEnvelop;
                pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                clsSnippet pSnippet = new clsSnippet();

                int intTLayerIdx = pSnippet.GetIndexNumberFromLayerName(pActiveView, strTargetLayerName);

                ILayer        pLayer         = mForm.axMapControl1.get_Layer(intTLayerIdx);
                IFeatureLayer pFLayer        = (IFeatureLayer)pLayer;
                string        ShapeFieldName = pFLayer.FeatureClass.ShapeFieldName;
                pSpatialFilter.GeometryField = pFLayer.FeatureClass.ShapeFieldName;
                IFeatureClass  pFeatureClass = pFLayer.FeatureClass;
                IFeatureCursor pFCursor      = pFeatureClass.Search(pSpatialFilter, false);
                IFeature       pFeature      = pFCursor.NextFeature();
                pFCursor.Flush();
                if (pFeature == null)
                {
                    return;
                }

                int intValueFldIdx = pFeatureClass.FindField(strValueField);
                int intUncerFldIdx = pFeatureClass.FindField(strUncerField);


                double[] dblValue = new double[1];
                dblValue[0] = Convert.ToDouble(pFeature.get_Value(intValueFldIdx));
                double[] dblUncern = new double[1];
                dblUncern[0] = Convert.ToDouble(pFeature.get_Value(intUncerFldIdx));
                REngine       pEngine  = mForm.pEngine;
                NumericVector vecValue = pEngine.CreateNumericVector(dblValue);
                NumericVector vecSD    = pEngine.CreateNumericVector(dblUncern);
                pEngine.SetSymbol("samp.mean", vecValue);
                pEngine.SetSymbol("samp.sd", vecSD);

                pEngine.Evaluate("samp.xlim <- c(samp.mean-(samp.sd*3), samp.mean+(samp.sd*3))");
                pEngine.Evaluate("confLevel <- " + pDrawDenplot.nudConfiLevel.Value.ToString());
                pEngine.Evaluate("bothlevel <- 1-((100-confLevel)/200)");
                pEngine.Evaluate("error <- qnorm(bothlevel)*samp.sd");
                pEngine.Evaluate("confint <- c(samp.mean-error, samp.mean+error)");

                StringBuilder sbCommand = new StringBuilder();
                sbCommand.Append("curve(dnorm(x, mean=samp.mean, sd=samp.sd), lwd=2, xlim=samp.xlim, ylab='Probability', xlab='" + strValueField + "');");
                sbCommand.Append("abline(v=samp.mean, col='red');");
                sbCommand.Append("abline(v=confint, col='blue');");
                string strTitle = "Probability Denstiy Plot";

                pSnippet.drawPlottoForm(strTitle, sbCommand.ToString());
            }

            //int intFID = Convert.ToInt32(pFeature.get_Value(0)); //Get FID Value
            //return intFID;



            //int intFID = FindFeatureFID(pPoint);
            //int intColumnLength = arrSimuResults.GetUpperBound(1) + 1;
            //double[] arrHist = new double[intColumnLength];
            //for (int i = 0; i < intColumnLength; i++)
            //{
            //    arrHist[i] = arrSimuResults[intFID, i];
            //}
            //NumericVector vecBLL = pEngine.CreateNumericVector(arrHist);
            //pEngine.SetSymbol(strValue, vecBLL);

            //string strCommand = "hist(" + strValue + ", freq=FALSE, main=paste('Histogram of FID ', " + intFID.ToString() + "));abline(v=" + Math.Round(arrOrivalue[intFID], 3).ToString() + ", col='red');";
            //string strTitle = "Histogram";

            //System.Text.StringBuilder CommandPlot = new System.Text.StringBuilder();
        }
示例#16
0
        private void btnSelect_Click(object sender, EventArgs e)
        {
            REngine    pEngine  = mForm.pEngine;
            clsSnippet pSnippet = new clsSnippet();

            string strBLLayerName = cboTargetLayer.Text;
            string strXFieldName  = cboXField.Text;
            string strYFieldName  = cboYField.Text;
            string strSALayerName = cboStudyArea.Text;

            int intLIndex  = pSnippet.GetIndexNumberFromLayerName(pActiveView, strSALayerName);
            int intBLIndex = pSnippet.GetIndexNumberFromLayerName(pActiveView, strBLLayerName);

            ILayer        pSALayer  = mForm.axMapControl1.get_Layer(intLIndex);
            IFeatureLayer pSAFLayer = (IFeatureLayer)pSALayer;
            IFeatureClass pSAFClass = pSAFLayer.FeatureClass;

            ILayer           pBLLayer     = mForm.axMapControl1.get_Layer(intBLIndex);
            IFeatureLayer    pBLFLayer    = (IFeatureLayer)pBLLayer;
            IGeoFeatureLayer pBLGeoFLayer = (IGeoFeatureLayer)pBLFLayer;
            IAttributeTable  pBLAttTable  = (IAttributeTable)pBLGeoFLayer;
            ITable           pBLTable     = (ITable)pBLAttTable;

            //Get File Name and Path
            IDataLayer   pSADLayer     = (IDataLayer)pSALayer;
            IDatasetName pSADSName     = (IDatasetName)pSADLayer.DataSourceName;
            string       strSAFCName   = pSADSName.Name;
            string       strSAFCPath   = pSADSName.WorkspaceName.PathName;
            string       strSAFullName = strSAFCPath + "\\" + strSAFCName + ".shp";
            IDataLayer   pBLDLayer     = (IDataLayer)pBLLayer;
            IDatasetName pBLDSName     = (IDatasetName)pBLDLayer.DataSourceName;
            string       strBLFCName   = pBLDSName.Name;
            string       strBLFCPath   = pBLDSName.WorkspaceName.PathName;
            string       strBLFullName = strBLFCPath + "\\" + strBLFCName + "1.dbf";;

            mForm       = System.Windows.Forms.Application.OpenForms["MainForm"] as MainForm;
            pActiveView = mForm.axMapControl1.ActiveView;
            IMap pMap = pActiveView.FocusMap;

            int intXFieldIdx = pBLFLayer.FeatureClass.Fields.FindField(strXFieldName) - 1; //-1 to use for R idx
            int intYFieldIdx = pBLFLayer.FeatureClass.Fields.FindField(strYFieldName) - 1;



            //StringBuilder plotCommmand = new StringBuilder();
            //plotCommmand.Append("library(circular);library(maptools);library(spdep);library(foreign);");
            //plotCommmand.Append("city.shp <- readShapePoly(" + strSAFullName + ");");
            //plotCommmand.Append("polycoords <- as.matrix(city.shp@polygons[[1]]@Polygons[[1]]@coords);");
            //plotCommmand.Append("bll.df <- as.data.frame(read.dbf(" + strBLFullName + ");");
            //plotCommmand.Append("del.row <- which(point.in.polygon(bll.df[,6],bll.df[,7],polycoords[,1],polycoords[,2])==0);");
            //plotCommmand.Append("hist(bll.df[,6])");
            //pEngine.Evaluate(plotCommmand.ToString());

            pEngine.Evaluate(@"library(circular);library(maptools);library(spdep);library(foreign)");
            pEngine.Evaluate(@"city.shp <- readShapePoly(" + strSAFullName + ")");
            //DataFrame pGV =pEngine.Evaluate(@"bll.df <- as.data.frame(read.dbf(" + strBLFullName + ")").AsDataFrame();
            //DataFrame pBLLdf = pEngine.
            pEngine.Evaluate("bll.df <- as.data.frame(read.dbf(\"" + strBLFullName + "\")");
            pEngine.Evaluate("hist(bll.df[,6])");



            // Get the table named XYSample.txt
            IStandaloneTableCollection pStTabCol;
            IStandaloneTable           pStandaloneTable;
            ITable pTable = null;

            pStTabCol = (IStandaloneTableCollection)pMap;
            for (int intCount = 0; intCount < pStTabCol.StandaloneTableCount; intCount++)
            {
                pStandaloneTable = (IStandaloneTable)pStTabCol.get_StandaloneTable(intCount);
                if (pStandaloneTable.Name == "syracuse-bll.csv")
                {
                    pTable = pStandaloneTable.Table;
                    break;
                }
            }
            if (pTable == null)
            {
                MessageBox.Show("The table was not found");
                return;
            }

            // Get the table name object
            IDataset pDataSet;
            IName    pTableName;

            pDataSet   = (IDataset)pTable;
            pTableName = pDataSet.FullName;

            // Specify the X and Y fields
            IXYEvent2FieldsProperties pXYEvent2FieldsProperties = new XYEvent2FieldsPropertiesClass();

            pXYEvent2FieldsProperties.XFieldName = cboXField.Text;
            pXYEvent2FieldsProperties.YFieldName = cboYField.Text;
            pXYEvent2FieldsProperties.ZFieldName = "";

            // Create the XY name object and set it's properties
            IXYEventSourceName pXYEventSourceName = new XYEventSourceNameClass();

            pXYEventSourceName.EventProperties = pXYEvent2FieldsProperties;
            IGeoDataset pGeoDataset = (IGeoDataset)pBLDLayer;

            pXYEventSourceName.SpatialReference = pGeoDataset.SpatialReference;
            //pXYEventSourceName.EventTableName = pTableName;

            IName          pXYName        = (IName)pXYEventSourceName;
            IXYEventSource pXYEventSource = (IXYEventSource)pXYName.Open();

            // Create a new Map Layer
            IFeatureLayer pFLayer = new FeatureLayerClass();

            pFLayer.FeatureClass = (IFeatureClass)pXYEventSource;
            pFLayer.Name         = "Sample XY Event layer";

            // Add the layer extension (this is done so that when you edit
            //   the layer's Source properties and click the Set Data Source
            //   button, the Add XY Events Dialog appears)
            //ILayerExtensions pLayerExt;
            //IFeatureLayerSourcePageExtension pRESPageExt = new XYDataSourcePageExtensionClass();
            //pLayerExt = (ILayerExtensions) pFLayer;
            //pLayerExt.AddExtension(pRESPageExt);

            pMap.AddLayer(pFLayer);
        }
示例#17
0
        private void btnApply_Click(object sender, EventArgs e)
        {
            try
            {
                //Declare variables
                clsSnippet pSnippet     = new clsSnippet();
                string     strLayerName = cboSourceLayer.Text;

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

                IFeatureLayer pFLayer = pLayer as IFeatureLayer;
                ESRI.ArcGIS.Geodatabase.IFeatureClass pFClass = pFLayer.FeatureClass;

                string strOriRenderField    = cboValueField.Text;
                string strUncernRenderField = cboUField.Text;
                double dblMinPtSize         = Convert.ToDouble(nudSymbolSize.Value);

                //Create New Layer?
                IGeoFeatureLayer pGeofeatureLayer = null;
                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;
                }

                //Find Fields
                ITable pTable       = (ITable)pFClass;
                int    intOriIdx    = pTable.FindField(strOriRenderField);
                int    intUncernIdx = pTable.FindField(strUncernRenderField);

                //Find Min and Max Ori Value
                IField          pOriField = pTable.Fields.get_Field(intOriIdx);
                ICursor         pCursor   = pTable.Search(null, true);
                IDataStatistics pDataStat = new DataStatisticsClass();
                pDataStat.Field  = pOriField.Name;
                pDataStat.Cursor = pCursor;
                IStatisticsResults pStatResults   = pDataStat.Statistics;
                double             dblMinOriValue = pStatResults.Minimum;
                double             dblMaxOriValue = pStatResults.Maximum;
                pCursor.Flush();

                //Find Min and Max Uncern Vale
                IField pUncernField = pTable.Fields.get_Field(intUncernIdx);
                pCursor          = pTable.Search(null, true);
                pDataStat        = new DataStatisticsClass();
                pDataStat.Field  = pUncernField.Name;
                pDataStat.Cursor = pCursor;
                pStatResults     = pDataStat.Statistics;
                double dblMinUncernValue = pStatResults.Minimum;
                double dblMaxUncernValue = pStatResults.Maximum;

                pCursor.Flush();

                //To adjust minn value to 1, if the min value is zero
                double dbladjuctMinvalue = 0;
                if (dblMinOriValue <= 0)
                {
                    dbladjuctMinvalue = (0 - dblMinOriValue) + 1;
                    dblMinOriValue    = dblMinOriValue + dbladjuctMinvalue;
                }

                IDisplay pDisplay = pActiveView.ScreenDisplay;

                IRgbColor pSymbolRgb = new RgbColorClass();
                pSymbolRgb.Red   = picSymbolColor.BackColor.R;
                pSymbolRgb.Green = picSymbolColor.BackColor.G;
                pSymbolRgb.Blue  = picSymbolColor.BackColor.B;

                IRgbColor pLineRgb = new RgbColorClass();
                pLineRgb.Red   = picLineColor.BackColor.R;
                pLineRgb.Green = picLineColor.BackColor.G;
                pLineRgb.Blue  = picLineColor.BackColor.B;

                int intMethods = 0;
                if (cboMethods.Text == "Saturation")
                {
                    intMethods = 1;
                }
                else if (cboMethods.Text == "Value")
                {
                    intMethods = 2;
                }
                else if (cboMethods.Text == "Whiteness")
                {
                    intMethods = 3;
                }

                IColoringProperties pPreUncern = new ColoringPropClass2();
                //IColoringProperties pPreUncern = new ColoringProp();
                pPreUncern.m_intMethods           = intMethods;
                pPreUncern.m_intOriLegendCount    = 3; //Needs to be changed
                pPreUncern.m_intUncernLegendCount = 3; //Needs to be changed


                pPreUncern.m_strOriRenderField    = strOriRenderField;
                pPreUncern.m_strUncernRenderField = strUncernRenderField;

                pPreUncern.m_pSymbolRgb          = pSymbolRgb;
                pPreUncern.m_pLineRgb            = pLineRgb;
                pPreUncern.m_dblOutlineSize      = Convert.ToDouble(nudLinewidth.Value);
                pPreUncern.m_dblAdjustedMinValue = dbladjuctMinvalue;
                pPreUncern.m_dblMinOriValue      = dblMinOriValue;
                pPreUncern.m_dblMaxOriValue      = dblMaxOriValue;
                pPreUncern.m_dblMinUncernValue   = dblMinUncernValue;
                pPreUncern.m_dblMaxUncernValue   = dblMaxUncernValue;
                pPreUncern.m_dblMinPtSize        = dblMinPtSize;

                pPreUncern.CreateLegend();
                pGeofeatureLayer.Renderer = (IFeatureRenderer)pPreUncern;


                if (chkNewLayer.Checked == true)
                {
                    mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGeofeatureLayer);
                }
                else
                {
                    pFLayer = (IFeatureLayer)pGeofeatureLayer;
                }


                mForm.axTOCControl1.Update();
                mForm.axMapControl1.ActiveView.Refresh();
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
示例#18
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;
            }
        }
示例#19
0
        private void btnApply_Click(object sender, EventArgs e)
        {
            //Choropleth mapping : Exactly same with the function in frmChoroplethwithOverlay HK102915
            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;

            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 TableHistogramClass();

            pTableHistogram.Field = strGCRenderField;
            pTableHistogram.Table = pTable;
            IHistogram pHistogram = (IHistogram)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;


            //////////////////The Robustness
            int    intRoundingDigits   = 2;
            int    intUncernBreakCount = Convert.ToInt32(nudTeNClasses.Value);
            string strUncerFieldName   = cboUField.Text;

            int intUncernIdx = pFClass.FindField(strUncerFieldName);
            int intValueIdx  = pFClass.FindField(strGCRenderField);

            //Calculate Robustness
            //Add fld
            int    intTempfldIdx  = 0;
            string strTempfldName = txtFldName.Text;

            if (chkRobustness.Checked)
            {
                if (pFClass.FindField(strTempfldName) == -1)
                {
                    AddField(pFClass, strTempfldName);
                }
                intTempfldIdx = pFClass.FindField(strTempfldName);
            }

            Chart pChart = new Chart();

            IFeature pFeat = null;
            //IFeatureCursor pFCursor = pFClass.Search(null, false);
            IFeatureCursor pFCursor = null;

            if (chkRobustness.Checked)
            {
                pFCursor = pFClass.Update(null, false);
            }
            else
            {
                pFCursor = pFClass.Search(null, false);
            }

            pFeat = pFCursor.NextFeature();
            double[] arrRobustness = new double[pFClass.FeatureCount(null)];

            int i = 0;

            while (pFeat != null)
            {
                for (int j = 0; j < (cb.Length - 1); j++)
                {
                    double dblValue = Convert.ToDouble(pFeat.get_Value(intValueIdx));
                    double dblStd   = Convert.ToDouble(pFeat.get_Value(intUncernIdx));
                    if (j == 0)
                    {
                        if (dblValue >= cb[j] && dblValue <= cb[j + 1])
                        {
                            double dblUpperZvalue  = (cb[j + 1] - dblValue) / dblStd;
                            double dblUpperConfLev = pChart.DataManipulator.Statistics.NormalDistribution(dblUpperZvalue);
                            double dblLowerZvalue  = (cb[j] - dblValue) / dblStd;
                            double dblLowerConfLev = pChart.DataManipulator.Statistics.NormalDistribution(dblLowerZvalue);
                            arrRobustness[i] = dblUpperConfLev - dblLowerConfLev;
                            if (chkRobustness.Checked)
                            {
                                pFeat.set_Value(intTempfldIdx, arrRobustness[i]);
                            }
                        }
                    }
                    else
                    {
                        if (dblValue > cb[j] && dblValue <= cb[j + 1])
                        {
                            double dblUpperZvalue  = (cb[j + 1] - dblValue) / dblStd;
                            double dblUpperConfLev = pChart.DataManipulator.Statistics.NormalDistribution(dblUpperZvalue);
                            double dblLowerZvalue  = (cb[j] - dblValue) / dblStd;
                            double dblLowerConfLev = pChart.DataManipulator.Statistics.NormalDistribution(dblLowerZvalue);
                            arrRobustness[i] = dblUpperConfLev - dblLowerConfLev;
                            if (chkRobustness.Checked)
                            {
                                pFeat.set_Value(intTempfldIdx, arrRobustness[i]);
                            }
                        }
                    }
                }
                if (chkRobustness.Checked)
                {
                    pFCursor.UpdateFeature(pFeat);
                }

                i++;
                pFeat = pFCursor.NextFeature();
            }

            //Define the intervals (the last class is fixed to 1)
            if (intUncernBreakCount == 1)
            {
                return;
            }

            double[] arrRobustBrks     = new double[intUncernBreakCount + 1];
            double   dblRBrksIntervals = Math.Round(1 / Convert.ToDouble(intUncernBreakCount - 1), intRoundingDigits);

            arrRobustBrks[0] = 0;
            for (int j = 1; j < intUncernBreakCount; j++)
            {
                arrRobustBrks[j] = dblRBrksIntervals * j;
            }
            arrRobustBrks[intUncernBreakCount] = 1;



            IFeatureLayer pflUncern = new FeatureLayerClass();

            pflUncern.FeatureClass = pFClass;
            pflUncern.Name         = "Robustness";
            pflUncern.Visible      = true;

            IGeoFeatureLayer pGFLUncern = (IGeoFeatureLayer)pflUncern;

            pFCursor = pGFLUncern.Search(null, true);
            RobustnessRenderer pRobustnessRenderer = new RobustnessRenderer();

            pRobustnessRenderer.arrRobustBrks       = arrRobustBrks;
            pRobustnessRenderer.arrRobustness       = arrRobustness;
            pRobustnessRenderer.dblAngle            = Convert.ToDouble(nudAngleFrom.Value);
            pRobustnessRenderer.dblFromSep          = Convert.ToDouble(nudSeperationFrom.Value);
            pRobustnessRenderer.dblLinewidth        = Convert.ToDouble(nudTeLinewidth.Value);
            pRobustnessRenderer.dblToSep            = Convert.ToDouble(nudSeperationTo.Value);
            pRobustnessRenderer.intUncernBreakCount = intUncernBreakCount;
            pRobustnessRenderer.pLineColor          = pSnippet.getRGB(picTeLineColor.BackColor.R, picTeLineColor.BackColor.G, picTeLineColor.BackColor.B);
            IQueryFilter pQFilter = new QueryFilterClass();


            pRobustnessRenderer.PrepareFilter(pFClass, pQFilter);
            pRobustnessRenderer.Draw(pFCursor, esriDrawPhase.esriDPSelection, pActiveView.ScreenDisplay, null);
            pRobustnessRenderer.CreateLegend();
            pGFLUncern.Renderer = pRobustnessRenderer;

            pActiveView.FocusMap.AddLayer(pGFLUncern as ILayer);

            mForm.axMapControl1.ActiveView.Refresh();
            mForm.axTOCControl1.Update();
        }
示例#20
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (pDrawDenplot.cboSourceLayer.Text != "" && pDrawDenplot.cboUField.Text != "" && pDrawDenplot.cboValueField.Text != "")
            {
                IGeoFeatureLayer pGeoFeatureLayer = pDrawDenplot.pGeofeatureLayer;

                mForm = System.Windows.Forms.Application.OpenForms["MainForm"] as MainForm;
                IActiveView pActiveView        = mForm.axMapControl1.ActiveView;
                string      strTargetLayerName = pDrawDenplot.cboSourceLayer.Text;
                string      strValueField      = pDrawDenplot.cboValueField.Text;
                string      strUncerField      = pDrawDenplot.cboUField.Text;

                clsSnippet pSnippet = new clsSnippet();

                //Using IRubberband
                IEnvelope pEnvelop = pSnippet.DrawRectangle(pActiveView);

                ISpatialFilter pSpatialFilter = new SpatialFilterClass();
                pSpatialFilter.Geometry   = pEnvelop;
                pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;

                int intTLayerIdx = pSnippet.GetIndexNumberFromLayerName(pActiveView, strTargetLayerName);

                ILayer        pLayer  = mForm.axMapControl1.get_Layer(intTLayerIdx);
                IFeatureLayer pFLayer = (IFeatureLayer)pLayer;

                string ShapeFieldName = pFLayer.FeatureClass.ShapeFieldName;
                pSpatialFilter.GeometryField = pFLayer.FeatureClass.ShapeFieldName;
                IFeatureClass pFeatureClass = pFLayer.FeatureClass;


                int intValueFldIdx = pFeatureClass.FindField(strValueField);
                int intUncerFldIdx = pFeatureClass.FindField(strUncerField);

                IFeatureCursor pFCursor = pGeoFeatureLayer.Search(pSpatialFilter, true);

                StackedChartRenderer pStackedChartRenderer = new StackedChartRenderer();

                pStackedChartRenderer.dblError               = pDrawDenplot.dblError;
                pStackedChartRenderer.intValueFldIdx         = intValueFldIdx;
                pStackedChartRenderer.intUncerFldIdx         = intUncerFldIdx;
                pStackedChartRenderer.dblMaxValue            = pDrawDenplot.dblMaxValue;
                pStackedChartRenderer.bln3Dfeature           = pDrawDenplot.bln3Dfeature;
                pStackedChartRenderer.m_strOriRenderField    = strValueField;
                pStackedChartRenderer.m_strUncernRenderField = strUncerField;

                pStackedChartRenderer.dblMaxEstimate = pDrawDenplot.dblMaxEstimate;
                pStackedChartRenderer.dblMaxUncern   = pDrawDenplot.dblMaxUncern;

                pStackedChartRenderer.m_pQueryFilter = pSpatialFilter as IQueryFilter;

                //pStackedChartRenderer.m_stackedChart = pGeoFeatureLayer.Renderer;

                //pStackedChartRenderer.PrepareFilter(pFeatureClass, pSpatialFilter);
                pStackedChartRenderer.m_pDisplay = pActiveView.ScreenDisplay;
                //pStackedChartRenderer.Draw(pFCursor, esriDrawPhase.esriDPSelection, pDisplay, null);
                //pStackedChartRenderer.CreateLegend();
                pGeoFeatureLayer.Renderer = pStackedChartRenderer;


                //mForm.axMapControl1.ActiveView.Refresh();
                pActiveView.Refresh();
            }
        }
示例#21
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            try
            {
                string strLayerName    = cboSourceLayer.Text;
                string strFieldName    = cboWeight.Text;
                int    intFlickerRate  = Convert.ToInt32(Convert.ToDouble(nudFlikerRate.Value) * 1000);
                short  intTransparency = Convert.ToInt16(nudTransparency.Value);
                btnStart.Text = "Hit Esc to Stop";

                if (strLayerName == "" || strFieldName == "")
                {
                    MessageBox.Show("Please select layer or field");
                    return;
                }
                if (strFieldName == "None")
                {
                    int    intLIndex = pSnippet.GetIndexNumberFromLayerName(pActiveView, strLayerName);
                    ILayer pLayer    = mForm.axMapControl1.get_Layer(intLIndex);

                    pFLayer = pLayer as IFeatureLayer;
                    string strOIDFieldNM = pFLayer.FeatureClass.OIDFieldName;

                    int intFeatureCounts = pFLayer.FeatureClass.FeatureCount(null);

                    pTrackCancel = new CancelTrackerClass();
                    pTrackCancel.CancelOnClick    = false;
                    pTrackCancel.CancelOnKeyPress = true;

                    ILayerEffects pLayerEffect = (ILayerEffects)pFLayer;
                    pLayerEffect.Transparency = intTransparency;
                    //pActiveView.Refresh();

                    while (pTrackCancel.Continue())
                    {
                        IFeatureLayerDefinition2 pFDefinition = (IFeatureLayerDefinition2)pFLayer;
                        pFDefinition.DefinitionExpression = strOIDFieldNM + " < 0";
                        pActiveView.Refresh();
                        System.Threading.Thread.Sleep(intFlickerRate);
                        if (pTrackCancel.Continue() == false)
                        {
                            pFDefinition.DefinitionExpression = strOIDFieldNM + " >= 0";
                            pActiveView.Refresh();
                            btnStart.Text             = "Start";
                            pLayerEffect.Transparency = 0;
                            break;
                        }
                        pFDefinition.DefinitionExpression = strOIDFieldNM + " >= 0";
                        pActiveView.Refresh();
                        System.Threading.Thread.Sleep(intFlickerRate);
                        if (pTrackCancel.Continue() == false)
                        {
                            pLayerEffect.Transparency = 0;
                            btnStart.Text             = "Start";
                            break;
                        }
                    }
                }
                else
                {
                    if (strFieldName == "")
                    {
                        return;
                    }
                    int      intNClasses = Convert.ToInt32(nudCoNClasses.Value);
                    double[] cb          = fnClassification(pFLayer, nudCoNClasses.Value, cboWeight.Text, cboCoClassify.Text);
                    fnBlinking(strLayerName, strFieldName, intFlickerRate, intNClasses, intTransparency, cb);
                }
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
示例#22
0
        private void btnRun_Click(object sender, EventArgs e)
        {
            try
            {
                string strLayerName  = cboTargetLayer.Text;
                string strIDFldName  = cboFieldName.Text;
                string strOutputName = txtOutput.Text;
                bool   blnRook       = true;

                if (strLayerName == "" || strIDFldName == "" || strOutputName == "")
                {
                    MessageBox.Show("Please select layer or fields");
                    return;
                }
                clsSnippet pSnippet  = new clsSnippet();
                int        intLIndex = pSnippet.GetIndexNumberFromLayerName(pActiveView, strLayerName);
                ILayer     pLayer    = mForm.axMapControl1.get_Layer(intLIndex);

                IFeatureLayer pFLayer = pLayer as IFeatureLayer;
                ESRI.ArcGIS.Geodatabase.IFeatureClass pFClass = pFLayer.FeatureClass;

                IFields        fields   = pFClass.Fields;
                IFeatureCursor pFCursor = pFClass.Search(null, false);

                IFeature pFeature = pFCursor.NextFeature();
                int      intIDIdx = pFCursor.FindField(strIDFldName);

                ISpatialFilter pSF = new SpatialFilterClass();


                IFeatureCursor pNBCursor  = null;
                IFeature       pNBFeature = null;
                int            NBNumber   = 0;
                string         strNBIDs   = null;

                ITopologicalOperator pTopoOp = (ITopologicalOperator)pFeature.Shape;
                pSF.Geometry   = pFeature.ShapeCopy;
                pSF.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;

                IPointCollection pPointCol;

                System.IO.StreamWriter pSW = new System.IO.StreamWriter(strOutputName);
                pSW.WriteLine("0 " + pFClass.FeatureCount(null).ToString() + " " + pFClass.AliasName + " " + strIDFldName);


                while (pFeature != null)
                {
                    NBNumber = 0;
                    strNBIDs = null;

                    pSF.Geometry   = pFeature.ShapeCopy;
                    pSF.SpatialRel = ESRI.ArcGIS.Geodatabase.esriSpatialRelEnum.esriSpatialRelIntersects;

                    pNBCursor  = pFClass.Search(pSF, true);
                    pNBFeature = pNBCursor.NextFeature();

                    while (pNBFeature != null)
                    {
                        if (pFeature.get_Value(intIDIdx).Equals(pNBFeature.get_Value(intIDIdx)))
                        {
                            //if(pFeature.get_Value(intIDIdx) == pNBFeature.get_Value(intIDIdx))
                            pNBFeature = pNBCursor.NextFeature();
                        }
                        else
                        {
                            NBNumber  = NBNumber + 1;
                            pPointCol = (IPointCollection)pTopoOp.Intersect(pNBFeature.Shape, esriGeometryDimension.esriGeometry0Dimension);
                            if (blnRook)
                            {
                                if (pPointCol.PointCount != 1)
                                {
                                    strNBIDs = strNBIDs + " " + pNBFeature.get_Value(intIDIdx);
                                }
                                else
                                {
                                    NBNumber -= 1;
                                }
                            }
                            else
                            {
                                strNBIDs = strNBIDs + " " + pNBFeature.get_Value(intIDIdx);
                            }

                            pNBFeature = pNBCursor.NextFeature();
                        }
                    }

                    pNBCursor.Flush();

                    if (NBNumber > 0)
                    {
                        pSW.WriteLine(pFeature.get_Value(intIDIdx).ToString() + " " + NBNumber.ToString());
                        pSW.WriteLine(strNBIDs.Substring(1));
                    }
                    else
                    {
                        pSW.WriteLine(pFeature.get_Value(intIDIdx).ToString() + " " + NBNumber.ToString());
                        pSW.WriteLine("");
                    }

                    pFeature = pFCursor.NextFeature();
                }

                pSW.Close();
                pSW.Dispose();

                MessageBox.Show(strOutputName + " is generated.");
                //this.Close();
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }