예제 #1
0
        private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            CalButton.Enabled = true;
            DataTable dataTable = e.Result as DataTable;

            if (dataTable == null)
            {
                return;
            }


            ClassCollectResultForm classCollectResultForm = new ClassCollectResultForm()
            {
                TopMost = true
            };

            if (_pointRadioChecked)
            {
                classCollectResultForm.nType = 0;
            }
            else
            {
                classCollectResultForm.nType = 1;
            }
            classCollectResultForm.ResultTable = dataTable;
            classCollectResultForm.ShowDialog();
        }
예제 #2
0
        private void CalButton_Click(object sender, EventArgs e)
        {
            Splash.Show();
            int       count     = this.Layerbox.CheckedItems.Count;
            int       num       = -1;
            DataTable dataTable = new DataTable();

            dataTable.Columns.Clear();
            Splash.Status = "状态: 正在汇总,请稍候...";
            if (this.PointRadio.Checked)
            {
                if (!dataTable.Columns.Contains("层名"))
                {
                    dataTable.Columns.Add("层名", typeof(string));
                }
                if (!dataTable.Columns.Contains("点性"))
                {
                    dataTable.Columns.Add("点性", typeof(string));
                }
                if (!dataTable.Columns.Contains("个数"))
                {
                    dataTable.Columns.Add("个数", typeof(int));
                }
                if (!dataTable.Columns.Contains("总数"))
                {
                    dataTable.Columns.Add("总数", typeof(int));
                }
                int num2 = 0;
                for (int i = 0; i < count; i++)
                {
                    int num3 = 0;
                    Splash.Status = "状态: 正在汇总" + this.Layerbox.CheckedItems[i] + ",请稍候...";
                    IFeatureLayer pPipeLayer =
                        ((ClassCollectformsUI.LayerboxItem) this.Layerbox.CheckedItems[i]).m_pPipeLayer;
                    IFields  fields    = pPipeLayer.FeatureClass.Fields;
                    IYTField fieldInfo = pPipeCfg.GetSpecialField(pPipeLayer.FeatureClass.AliasName,
                                                                  PipeConfigWordHelper.PointWords.TZW);
                    string pointTableFieldName = fieldInfo.Name;
                    int    num4 = fields.FindField(pointTableFieldName);
                    if (num4 >= 0)
                    {
                        string         name          = pPipeLayer.Name;
                        ISpatialFilter spatialFilter = new SpatialFilter();
                        IFeatureClass  featureClass  = pPipeLayer.FeatureClass;
                        if (this.GeometrySet.Checked)
                        {
                            if (this.m_ipGeo != null)
                            {
                                spatialFilter.Geometry = (this.m_ipGeo);
                            }
                            spatialFilter.SpatialRel = (esriSpatialRelEnum)(1);
                        }
                        ISelectionSet selectionSet = featureClass.Select(spatialFilter, (esriSelectionType)3,
                                                                         (esriSelectionOption)1, null);
                        ITableSort tableSort = new TableSort();
                        tableSort.Fields       = (pointTableFieldName);
                        tableSort.SelectionSet = (selectionSet);
                        tableSort.Sort(null);
                        ICursor rows = tableSort.Rows;
                        object  obj  = null;
                        int     num5 = 1;
                        for (IRow row = rows.NextRow(); row != null; row = rows.NextRow())
                        {
                            object obj2 = row.Value[num4];
                            if (obj == null || !this.ColumnEqual(obj, obj2))
                            {
                                if (obj == null)
                                {
                                    obj = obj2;
                                }
                                else
                                {
                                    dataTable.Rows.Add(new object[]
                                    {
                                        name,
                                        obj,
                                        num5
                                    });
                                    num3 += num5;
                                    obj   = obj2;
                                    num5  = 1;
                                }
                            }
                            else
                            {
                                num5++;
                            }
                        }
                        num3 += num5;
                        num2 += num3;
                        dataTable.Rows.Add(new object[]
                        {
                            name,
                            obj,
                            num5,
                            num3
                        });
                    }
                }
                object[] array = new object[4];
                array.SetValue("合计", 1);
                array.SetValue(num2, 3);
                dataTable.Rows.Add(array);
            }
            else
            {
                if (!dataTable.Columns.Contains("层名"))
                {
                    dataTable.Columns.Add("层名", typeof(string));
                }
                if (!dataTable.Columns.Contains("规格"))
                {
                    dataTable.Columns.Add("规格", typeof(string));
                }
                if (!dataTable.Columns.Contains("材质"))
                {
                    dataTable.Columns.Add("材质", typeof(string));
                }
                if (!dataTable.Columns.Contains("条数"))
                {
                    dataTable.Columns.Add("条数", typeof(int));
                }
                if (!dataTable.Columns.Contains("长度"))
                {
                    dataTable.Columns.Add("长度", typeof(double));
                }
                if (!dataTable.Columns.Contains("总条数"))
                {
                    dataTable.Columns.Add("总条数", typeof(int));
                }
                if (!dataTable.Columns.Contains("总长度"))
                {
                    dataTable.Columns.Add("总长度", typeof(double));
                }
                int    num6 = 0;
                double num7 = 0.0;
                for (int j = 0; j < count; j++)
                {
                    int    num8 = 0;
                    double num9 = 0.0;
                    Splash.Status = "状态: 正在汇总" + this.Layerbox.CheckedItems[j] + ",请稍候...";
                    IFeatureLayer pPipeLayer =
                        ((ClassCollectformsUI.LayerboxItem) this.Layerbox.CheckedItems[j]).m_pPipeLayer;
                    IFields         fields2            = pPipeLayer.FeatureClass.Fields;
                    IBasicLayerInfo layerInfo          = pPipeCfg.GetBasicLayerInfo(pPipeLayer.FeatureClass);
                    string          lineTableFieldName = layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.GJ);

                    int    num4 = fields2.FindField(lineTableFieldName);
                    string lineTableFieldName2 = layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.DMCC);
                    // this.pPipeCfg.GetLineTableFieldName("断面尺寸");
                    int    num10 = fields2.FindField(lineTableFieldName2);
                    string lineTableFieldName3 = layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.GXCZ);
                    // this.pPipeCfg.GetLineTableFieldName("材质");
                    int num11 = fields2.FindField(lineTableFieldName3);
                    for (int k = 0; k < fields2.FieldCount; k++)
                    {
                        IField field = fields2.Field[k];
                        if (field.Type == (esriFieldType)7)
                        {
                            num = k;
                            break;
                        }
                    }
                    if (num4 >= 0 || num10 >= 0)
                    {
                        string         name           = pPipeLayer.Name;
                        ISpatialFilter spatialFilter2 = new SpatialFilter();
                        IFeatureClass  featureClass2  = pPipeLayer.FeatureClass;
                        if (this.GeometrySet.Checked)
                        {
                            if (this.m_ipGeo != null)
                            {
                                spatialFilter2.Geometry = (this.m_ipGeo);
                            }
                            spatialFilter2.SpatialRel = (esriSpatialRelEnum)(1);
                        }
                        ISelectionSet selectionSet2 = featureClass2.Select(spatialFilter2, (esriSelectionType)3,
                                                                           (esriSelectionOption)1, null);
                        ITableSort tableSort2 = new TableSort();
                        tableSort2.Fields = (string.Concat(new string[]
                        {
                            lineTableFieldName,
                            ",",
                            lineTableFieldName2,
                            ",",
                            lineTableFieldName3
                        }));
                        tableSort2.SelectionSet = (selectionSet2);
                        tableSort2.Sort(null);
                        ICursor rows2 = tableSort2.Rows;
                        object  obj3  = null;
                        object  obj4  = null;
                        int     num12 = 1;
                        IRow    row2  = rows2.NextRow();
                        double  num13 = 0.0;
                        while (row2 != null)
                        {
                            object obj5 = row2.Value[num4];
                            if (obj5 is DBNull || obj5.ToString() == "0")
                            {
                                obj5 = row2.Value[num10];
                            }
                            object obj6 = row2.Value[num11];
                            if (row2.Value[num] is DBNull)
                            {
                                row2 = rows2.NextRow();
                            }
                            else
                            {
                                IPolyline        polyline        = (IPolyline)row2.Value[num];
                                IPointCollection pointCollection = (IPointCollection)polyline;
                                double           num14           = 0.0;
                                for (int l = 0; l < pointCollection.PointCount - 1; l++)
                                {
                                    IPoint point  = pointCollection.Point[l];
                                    IPoint point2 = pointCollection.Point[l + 1];
                                    num14 +=
                                        Math.Sqrt(Math.Pow(point.X - point2.X, 2.0) + Math.Pow(point.Y - point2.Y, 2.0) +
                                                  Math.Pow(point.Z - point.M - point2.Z + point2.M, 2.0));
                                }
                                if (obj3 == null || !this.ColumnEqual(obj3, obj5))
                                {
                                    if (obj3 == null)
                                    {
                                        obj3   = obj5;
                                        num13 += num14;
                                    }
                                    else
                                    {
                                        num13 = Math.Round(num13, 3);
                                        dataTable.Rows.Add(new object[]
                                        {
                                            name,
                                            obj3,
                                            obj4,
                                            num12,
                                            num13
                                        });
                                        num8 += num12;
                                        num9 += num13;
                                        obj3  = obj5;
                                        obj4  = null;
                                        num13 = num14;
                                        num12 = 1;
                                    }
                                }
                                else if (obj4 == null || !this.ColumnEqual(obj4, obj6))
                                {
                                    if (obj4 == null)
                                    {
                                        obj4   = obj6;
                                        num13 += num14;
                                        num12++;
                                    }
                                    else
                                    {
                                        num13 = Math.Round(num13, 3);
                                        dataTable.Rows.Add(new object[]
                                        {
                                            name,
                                            obj3,
                                            obj4,
                                            num12,
                                            num13
                                        });
                                        num8 += num12;
                                        num9 += num13;
                                        num13 = num14;
                                        obj4  = obj6;
                                        num12 = 1;
                                    }
                                }
                                else
                                {
                                    num13 += num14;
                                    num12++;
                                }
                                row2 = rows2.NextRow();
                            }
                        }
                        num8 += num12;
                        num9 += num13;
                        num6 += num8;
                        num7 += num9;
                        num13 = Math.Round(num13, 3);
                        num9  = Math.Round(num9, 3);
                        dataTable.Rows.Add(new object[]
                        {
                            name,
                            obj3,
                            obj4,
                            num12,
                            num13,
                            num8,
                            num9
                        });
                    }
                }
                num7 = Math.Round(num7, 3);
                object[] array2 = new object[7];
                array2.SetValue("合计", 1);
                array2.SetValue(num6, 5);
                array2.SetValue(num7, 6);
                dataTable.Rows.Add(array2);
            }
            Splash.Close();
            ClassCollectResultForm classCollectResultForm = new ClassCollectResultForm();

            if (this.PointRadio.Checked)
            {
                classCollectResultForm.nType = 0;
            }
            else
            {
                classCollectResultForm.nType = 1;
            }
            classCollectResultForm.ResultTable = dataTable;
            classCollectResultForm.ShowDialog();
        }