/// <summary>
        ///     见煤钻孔
        /// </summary>
        /// <params name="breholeEntity">钻孔实体</params>
        /// <params name="subBoreholeEntity">钻孔岩性实体</params>
        private void DrawZuanKong(Borehole breholeEntity, SubBorehole subBoreholeEntity)
        {
            ////1.获得当前编辑图层
            //DrawSpecialCommon drawspecial = new DrawSpecialCommon();
            //string sLayerAliasName = LibCommon.LibLayerNames.DEFALUT_BOREHOLE;//“钻孔”图层
            //IFeatureLayer featureLayer = drawspecial.GetFeatureLayerByName(sLayerAliasName);
            //if (featureLayer == null)
            //{
            //    MessageBox.Show("未找到" + sLayerAliasName + "图层,无法绘制钻孔图元。");
            //    return;
            //}

            ////2.绘制图元
            //IPoint pt = new PointClass();
            //pt.X = breholeEntity.CoordinateX;
            //pt.Y = breholeEntity.CoordinateY;
            //pt.Z = breholeEntity.CoordinateZ;

            ////标注内容
            //string strH = breholeEntity.GroundElevation.ToString();//地面标高
            //string strName = breholeEntity.BoreholeNumber.ToString();//孔号(名称)
            //string strDBBG = subBoreholeEntity.FloorElevation.ToString();//底板标高
            //string strMCHD = subBoreholeEntity.Thickness.ToString();//煤层厚度

            //GIS.SpecialGraphic.DrawZK1 drawZK1 = new GIS.SpecialGraphic.DrawZK1(strName, strH, strDBBG, strMCHD);
            //DataEditCommon.g_CurWorkspaceEdit.StartEditing(false);
            //DataEditCommon.g_CurWorkspaceEdit.StartEditOperation();
            //IFeature feature = featureLayer.FeatureClass.CreateFeature();

            //IGeometry geometry = pt;
            //DataEditCommon.ZMValue(feature, geometry);   //几何图形Z值处理
            ////drawspecial.ZMValue(feature, geometry);//几何图形Z值处理
            //feature.Shape = pt;//要素形状
            ////要素ID字段赋值(对应属性表中BindingID)
            //int iFieldID = feature.Fields.FindField("BID");
            //feature.Value[iFieldID] =breholeEntity.bid.ToString();
            //feature.Store();//存储要素
            //DataEditCommon.g_CurWorkspaceEdit.StopEditOperation();
            //DataEditCommon.g_CurWorkspaceEdit.StopEditing(true);
            //string strValue = feature.get_Value(feature.Fields.FindField("OBJECTID")).ToString();
            //DataEditCommon.SpecialPointRenderer(featureLayer, "OBJECTID", strValue, drawZK1.m_Bitmap);

            /////3.显示钻孔图层
            //if (featureLayer.Visible == false)
            //    featureLayer.Visible = true;

            //IEnvelope envelop = feature.Shape.Envelope;
            //DataEditCommon.g_pMyMapCtrl.ActiveView.Extent = envelop;
            //DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null);
            //DataEditCommon.g_pMyMapCtrl.ActiveView.Refresh();

            IPoint pt = new PointClass();
            pt.X = breholeEntity.coordinate_x;
            pt.Y = breholeEntity.coordinate_y;
            pt.Z = breholeEntity.coordinate_z;
            if (double.IsNaN(pt.Z))
                pt.Z = 0;
            var pLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.DEFALUT_BOREHOLE);
            if (pLayer == null)
            {
                MessageBox.Show(@"未找到钻孔图层,无法绘制钻孔图元。");
                return;
            }
            var pFeatureLayer = (IFeatureLayer)pLayer;
            IGeometry geometry = pt;
            var list = new List<ziduan>
            {
                new ziduan("bid", breholeEntity.bid),
                new ziduan("BOREHOLE_NUMBER", breholeEntity.name),
                new ziduan("addtime", DateTime.Now.ToString(CultureInfo.InvariantCulture)),
                new ziduan("GROUND_ELEVATION", breholeEntity.ground_elevation.ToString(CultureInfo.InvariantCulture)),
                new ziduan("FLOOR_ELEVATION",
                    subBoreholeEntity.floor_elevation.ToString(CultureInfo.InvariantCulture)),
                new ziduan("THICKNESS", subBoreholeEntity.thickness.ToString(CultureInfo.InvariantCulture)),
                new ziduan("type", "2")
            };

            var pfeature = DataEditCommon.CreateNewFeature(pFeatureLayer, geometry, list);
            if (pfeature != null)
            {
                MyMapHelp.Jump(pt);
                DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(
                    (esriViewDrawPhase)34, null, null);
            }
        }
        /// <summary>
        ///     提  交
        /// </summary>
        /// <params name="sender"></params>
        /// <params name="e"></params>
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            var borehole = Borehole.FindAllByProperty("name", txtBoreholeNumber.Text).FirstOrDefault() ??
                           new Borehole { bid = IdGenerator.NewBindingId() };
            borehole.name = txtBoreholeNumber.Text.Trim();
            borehole.ground_elevation = Convert.ToDouble(txtGroundElevation.Text.Trim());
            borehole.coordinate_x = Convert.ToDouble(txtCoordinateX.Text.Trim());
            borehole.coordinate_y = Convert.ToDouble(txtCoordinateY.Text.Trim());
            borehole.coordinate_z = Convert.ToDouble(txtCoordinateZ.Text.Trim());
            borehole.coal_seam_texture = string.Empty;
            borehole.Save();
            var subBorehole = new SubBorehole();
            for (var i = 0; i < gvCoalSeamsTexture.RowCount; i++)
            {
                // 最后一行为空行时,跳出循环
                if (i == gvCoalSeamsTexture.RowCount - 1)
                {
                    break;
                }

                // 创建钻孔岩性实体
                subBorehole = new SubBorehole
                {
                    floor_elevation = Convert.ToDouble(gvCoalSeamsTexture.Rows[i].Cells[1].Value),
                    thickness = Convert.ToDouble(gvCoalSeamsTexture.Rows[i].Cells[2].Value),
                    coal_seam = gvCoalSeamsTexture.Rows[i].Cells[3].Value.ToString(),
                    coordinate_x = Convert.ToDouble(gvCoalSeamsTexture.Rows[i].Cells[4].Value),
                    coordinate_y = Convert.ToDouble(gvCoalSeamsTexture.Rows[i].Cells[5].Value),
                    coordinate_z = Convert.ToDouble(gvCoalSeamsTexture.Rows[i].Cells[6].Value),
                    lithology = gvCoalSeamsTexture.Rows[i].Cells[0].Value.ToString(),
                    borehole = borehole
                };
                subBorehole.Save();
            }

            var drawspecial = new DrawSpecialCommon();
            const string sLayerAliasName = LayerNames.DEFALUT_BOREHOLE; //“钻孔”图层
            var featureLayer = drawspecial.GetFeatureLayerByName(sLayerAliasName);
            if (featureLayer == null)
            {
                MessageBox.Show(@"未找到" + sLayerAliasName + @"图层,无法删钻孔图元。");
                return;
            }

            if (borehole.id != 0)
            {
                DataEditCommon.DeleteFeatureByBId(featureLayer, borehole.bid);
            }

            var dlgResult = MessageBox.Show(@"是:见煤钻孔,否:未见煤钻孔,取消:不绘制钻孔",
                @"绘制钻孔", MessageBoxButtons.YesNoCancel);

            borehole = Borehole.FindAllByProperty("name", borehole.name).First();
            switch (dlgResult)
            {
                case DialogResult.Yes:
                    DrawZuanKong(borehole, subBorehole);
                    break;
                case DialogResult.No:
                    DrawZuanKong(borehole);
                    break;
                case DialogResult.Cancel:
                    break;
            }
            DialogResult = DialogResult.OK;
        }
        private void btnReadMultTxt_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog
            {
                RestoreDirectory = true,
                Filter = @"文本文件(*.txt)|*.txt|所有文件(*.*)|*.*",
                Multiselect = true
            };
            if (ofd.ShowDialog() != DialogResult.OK) return;
            _errorMsg = @"失败文件名:";
            pbCount.Maximum = ofd.FileNames.Length;
            pbCount.Value = 0;
            lblTotal.Text = ofd.FileNames.Length.ToString(CultureInfo.InvariantCulture);
            foreach (var fileName in ofd.FileNames)
            {
                var encoder = TxtFileEncoding.GetEncoding(fileName, Encoding.GetEncoding("GB2312"));

                var sr = new StreamReader(fileName, encoder);
                string duqu;
                while ((duqu = sr.ReadLine()) != null)
                {
                    try
                    {
                        var str = duqu.Split('|');
                        var borehole = Borehole.FindAllByProperty("name", str[0]).FirstOrDefault() ??
                                       new Borehole { bid = IdGenerator.NewBindingId() };

                        borehole.name = str[0];
                        borehole.ground_elevation = Convert.ToDouble(str[3]);
                        borehole.coordinate_x = Convert.ToDouble(str[1].Split(',')[0]);
                        borehole.coordinate_y = Convert.ToDouble(str[1].Split(',')[1]);
                        borehole.coordinate_z = 0;
                        borehole.coal_seam_texture = String.Empty;
                        // 创建钻孔岩性实体
                        var boreholeLithology = new SubBorehole
                        {
                            borehole = borehole,
                            lithology = "煤层",
                            floor_elevation = Convert.ToDouble(str[4]),
                            coal_seam = ConfigHelper.current_seam.name,
                            thickness = Convert.ToDouble(str[2]),
                            coordinate_x = Convert.ToDouble(str[1].Split(',')[0]),
                            coordinate_y = Convert.ToDouble(str[1].Split(',')[1]),
                            coordinate_z = 0
                        };

                        borehole.sub_boreholes = new[] { boreholeLithology };
                        DrawZuanKong(borehole, boreholeLithology);
                        borehole.Save();
                    }
                    catch (Exception)
                    {
                        lblError.Text =
                            (Convert.ToInt32(lblError.Text) + 1).ToString(CultureInfo.InvariantCulture);
                        lblSuccessed.Text =
                            (Convert.ToInt32(lblSuccessed.Text) - 1).ToString(CultureInfo.InvariantCulture);
                        _errorMsg += fileName.Substring(fileName.LastIndexOf(@"\", StringComparison.Ordinal) + 1) + "\n";
                        btnDetails.Enabled = true;
                    }
                }
                lblSuccessed.Text =
                    (Convert.ToInt32(lblSuccessed.Text) + 1).ToString(CultureInfo.InvariantCulture);
                pbCount.Value++;
            }
            Alert.AlertMsg("导入成功!");
        }
Пример #4
0
        /// <summary>
        ///     提  交
        /// </summary>
        /// <params name="sender"></params>
        /// <params name="e"></params>
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            var borehole = Borehole.FindAllByProperty("name", txtBoreholeNumber.Text).FirstOrDefault() ??
                           new Borehole {
                bid = IdGenerator.NewBindingId()
            };

            borehole.name              = txtBoreholeNumber.Text.Trim();
            borehole.ground_elevation  = Convert.ToDouble(txtGroundElevation.Text.Trim());
            borehole.coordinate_x      = Convert.ToDouble(txtCoordinateX.Text.Trim());
            borehole.coordinate_y      = Convert.ToDouble(txtCoordinateY.Text.Trim());
            borehole.coordinate_z      = Convert.ToDouble(txtCoordinateZ.Text.Trim());
            borehole.coal_seam_texture = string.Empty;
            borehole.Save();
            var subBorehole = new SubBorehole();

            for (var i = 0; i < gvCoalSeamsTexture.RowCount; i++)
            {
                // 最后一行为空行时,跳出循环
                if (i == gvCoalSeamsTexture.RowCount - 1)
                {
                    break;
                }

                // 创建钻孔岩性实体
                subBorehole = new SubBorehole
                {
                    floor_elevation = Convert.ToDouble(gvCoalSeamsTexture.Rows[i].Cells[1].Value),
                    thickness       = Convert.ToDouble(gvCoalSeamsTexture.Rows[i].Cells[2].Value),
                    coal_seam       = gvCoalSeamsTexture.Rows[i].Cells[3].Value.ToString(),
                    coordinate_x    = Convert.ToDouble(gvCoalSeamsTexture.Rows[i].Cells[4].Value),
                    coordinate_y    = Convert.ToDouble(gvCoalSeamsTexture.Rows[i].Cells[5].Value),
                    coordinate_z    = Convert.ToDouble(gvCoalSeamsTexture.Rows[i].Cells[6].Value),
                    lithology       = gvCoalSeamsTexture.Rows[i].Cells[0].Value.ToString(),
                    borehole        = borehole
                };
                subBorehole.Save();
            }

            var          drawspecial     = new DrawSpecialCommon();
            const string sLayerAliasName = LayerNames.DEFALUT_BOREHOLE; //“钻孔”图层
            var          featureLayer    = drawspecial.GetFeatureLayerByName(sLayerAliasName);

            if (featureLayer == null)
            {
                MessageBox.Show(@"未找到" + sLayerAliasName + @"图层,无法删钻孔图元。");
                return;
            }

            if (borehole.id != 0)
            {
                DataEditCommon.DeleteFeatureByBId(featureLayer, borehole.bid);
            }

            var dlgResult = MessageBox.Show(@"是:见煤钻孔,否:未见煤钻孔,取消:不绘制钻孔",
                                            @"绘制钻孔", MessageBoxButtons.YesNoCancel);

            borehole = Borehole.FindAllByProperty("name", borehole.name).First();
            switch (dlgResult)
            {
            case DialogResult.Yes:
                DrawZuanKong(borehole, subBorehole);
                break;

            case DialogResult.No:
                DrawZuanKong(borehole);
                break;

            case DialogResult.Cancel:
                break;
            }
            DialogResult = DialogResult.OK;
        }
Пример #5
0
        /// <summary>
        ///     见煤钻孔
        /// </summary>
        /// <params name="breholeEntity">钻孔实体</params>
        /// <params name="subBoreholeEntity">钻孔岩性实体</params>
        private void DrawZuanKong(Borehole breholeEntity, SubBorehole subBoreholeEntity)
        {
            ////1.获得当前编辑图层
            //DrawSpecialCommon drawspecial = new DrawSpecialCommon();
            //string sLayerAliasName = LibCommon.LibLayerNames.DEFALUT_BOREHOLE;//“钻孔”图层
            //IFeatureLayer featureLayer = drawspecial.GetFeatureLayerByName(sLayerAliasName);
            //if (featureLayer == null)
            //{
            //    MessageBox.Show("未找到" + sLayerAliasName + "图层,无法绘制钻孔图元。");
            //    return;
            //}

            ////2.绘制图元
            //IPoint pt = new PointClass();
            //pt.X = breholeEntity.CoordinateX;
            //pt.Y = breholeEntity.CoordinateY;
            //pt.Z = breholeEntity.CoordinateZ;

            ////标注内容
            //string strH = breholeEntity.GroundElevation.ToString();//地面标高
            //string strName = breholeEntity.BoreholeNumber.ToString();//孔号(名称)
            //string strDBBG = subBoreholeEntity.FloorElevation.ToString();//底板标高
            //string strMCHD = subBoreholeEntity.Thickness.ToString();//煤层厚度

            //GIS.SpecialGraphic.DrawZK1 drawZK1 = new GIS.SpecialGraphic.DrawZK1(strName, strH, strDBBG, strMCHD);
            //DataEditCommon.g_CurWorkspaceEdit.StartEditing(false);
            //DataEditCommon.g_CurWorkspaceEdit.StartEditOperation();
            //IFeature feature = featureLayer.FeatureClass.CreateFeature();

            //IGeometry geometry = pt;
            //DataEditCommon.ZMValue(feature, geometry);   //几何图形Z值处理
            ////drawspecial.ZMValue(feature, geometry);//几何图形Z值处理
            //feature.Shape = pt;//要素形状
            ////要素ID字段赋值(对应属性表中BindingID)
            //int iFieldID = feature.Fields.FindField("BID");
            //feature.Value[iFieldID] =breholeEntity.bid.ToString();
            //feature.Store();//存储要素
            //DataEditCommon.g_CurWorkspaceEdit.StopEditOperation();
            //DataEditCommon.g_CurWorkspaceEdit.StopEditing(true);
            //string strValue = feature.get_Value(feature.Fields.FindField("OBJECTID")).ToString();
            //DataEditCommon.SpecialPointRenderer(featureLayer, "OBJECTID", strValue, drawZK1.m_Bitmap);

            /////3.显示钻孔图层
            //if (featureLayer.Visible == false)
            //    featureLayer.Visible = true;

            //IEnvelope envelop = feature.Shape.Envelope;
            //DataEditCommon.g_pMyMapCtrl.ActiveView.Extent = envelop;
            //DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null);
            //DataEditCommon.g_pMyMapCtrl.ActiveView.Refresh();

            IPoint pt = new PointClass();

            pt.X = breholeEntity.coordinate_x;
            pt.Y = breholeEntity.coordinate_y;
            pt.Z = breholeEntity.coordinate_z;
            if (double.IsNaN(pt.Z))
            {
                pt.Z = 0;
            }
            var pLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.DEFALUT_BOREHOLE);

            if (pLayer == null)
            {
                MessageBox.Show(@"未找到钻孔图层,无法绘制钻孔图元。");
                return;
            }
            var       pFeatureLayer = (IFeatureLayer)pLayer;
            IGeometry geometry      = pt;
            var       list          = new List <ziduan>
            {
                new ziduan("bid", breholeEntity.bid),
                new ziduan("BOREHOLE_NUMBER", breholeEntity.name),
                new ziduan("addtime", DateTime.Now.ToString(CultureInfo.InvariantCulture)),
                new ziduan("GROUND_ELEVATION", breholeEntity.ground_elevation.ToString(CultureInfo.InvariantCulture)),
                new ziduan("FLOOR_ELEVATION",
                           subBoreholeEntity.floor_elevation.ToString(CultureInfo.InvariantCulture)),
                new ziduan("THICKNESS", subBoreholeEntity.thickness.ToString(CultureInfo.InvariantCulture)),
                new ziduan("type", "2")
            };

            var pfeature = DataEditCommon.CreateNewFeature(pFeatureLayer, geometry, list);

            if (pfeature != null)
            {
                MyMapHelp.Jump(pt);
                DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(
                    (esriViewDrawPhase)34, null, null);
            }
        }
Пример #6
0
        private void btnReadMultTxt_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog
            {
                RestoreDirectory = true,
                Filter           = @"文本文件(*.txt)|*.txt|所有文件(*.*)|*.*",
                Multiselect      = true
            };

            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            _errorMsg       = @"失败文件名:";
            pbCount.Maximum = ofd.FileNames.Length;
            pbCount.Value   = 0;
            lblTotal.Text   = ofd.FileNames.Length.ToString(CultureInfo.InvariantCulture);
            foreach (var fileName in ofd.FileNames)
            {
                var encoder = TxtFileEncoding.GetEncoding(fileName, Encoding.GetEncoding("GB2312"));

                var    sr = new StreamReader(fileName, encoder);
                string duqu;
                while ((duqu = sr.ReadLine()) != null)
                {
                    try
                    {
                        var str      = duqu.Split('|');
                        var borehole = Borehole.FindAllByProperty("name", str[0]).FirstOrDefault() ??
                                       new Borehole {
                            bid = IdGenerator.NewBindingId()
                        };

                        borehole.name              = str[0];
                        borehole.ground_elevation  = Convert.ToDouble(str[3]);
                        borehole.coordinate_x      = Convert.ToDouble(str[1].Split(',')[0]);
                        borehole.coordinate_y      = Convert.ToDouble(str[1].Split(',')[1]);
                        borehole.coordinate_z      = 0;
                        borehole.coal_seam_texture = String.Empty;
                        // 创建钻孔岩性实体
                        var boreholeLithology = new SubBorehole
                        {
                            borehole        = borehole,
                            lithology       = "煤层",
                            floor_elevation = Convert.ToDouble(str[4]),
                            coal_seam       = ConfigHelper.current_seam.name,
                            thickness       = Convert.ToDouble(str[2]),
                            coordinate_x    = Convert.ToDouble(str[1].Split(',')[0]),
                            coordinate_y    = Convert.ToDouble(str[1].Split(',')[1]),
                            coordinate_z    = 0
                        };

                        borehole.sub_boreholes = new[] { boreholeLithology };
                        DrawZuanKong(borehole, boreholeLithology);
                        borehole.Save();
                    }
                    catch (Exception)
                    {
                        lblError.Text =
                            (Convert.ToInt32(lblError.Text) + 1).ToString(CultureInfo.InvariantCulture);
                        lblSuccessed.Text =
                            (Convert.ToInt32(lblSuccessed.Text) - 1).ToString(CultureInfo.InvariantCulture);
                        _errorMsg         += fileName.Substring(fileName.LastIndexOf(@"\", StringComparison.Ordinal) + 1) + "\n";
                        btnDetails.Enabled = true;
                    }
                }
                lblSuccessed.Text =
                    (Convert.ToInt32(lblSuccessed.Text) + 1).ToString(CultureInfo.InvariantCulture);
                pbCount.Value++;
            }
            Alert.AlertMsg("导入成功!");
        }