Beispiel #1
0
 private void FrmNorthArrow_Load(object sender, EventArgs e)
 {
     try
     {
         //加载指北针样式
         string EsriStylePath = ClsGDBDataCommon.GetParentPathofExe() + @"Resource\Style\ESRI.ServerStyle";
         axSymbologyControl.LoadStyleFile(EsriStylePath);
         axSymbologyControl.StyleClass = esriSymbologyStyleClass.esriStyleClassNorthArrows;
         ISymbologyStyleClass symbologyStyleClass = axSymbologyControl.GetStyleClass(axSymbologyControl.StyleClass);
         if (m_pNorthArrow != null)
         {
             m_pStyleGalleryItem      = new ServerStyleGalleryItem();
             m_pStyleGalleryItem.Item = m_pNorthArrow;
             symbologyStyleClass.AddItem(m_pStyleGalleryItem, 0);
         }
         symbologyStyleClass.SelectItem(0);
         ////选择第一个指北针样式为预定样式
         //SetFeatureClassStyle(esriSymbologyStyleClass.esriStyleClassNorthArrows);
         ////默认设置
         //角度设置
         this.NorthArrowAngle.Value = 0;
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #2
0
        private void buttonX_ok_Click(object sender, EventArgs e)
        {
            CGmpPoint xml    = new CGmpPoint();
            bool      result = xml.ReadGmpXML(XMLPath);
            Regex     regNum = new Regex("^[0-9]");

            if (regNum.IsMatch(textBoxX3.Text) == true)
            {
                MessageBox.Show("数据集名称不能以数字开头命名", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (result == true)
            {
                try
                {
                    IWorkspaceFactory workspaceFactory = new FileGDBWorkspaceFactoryClass();
                    gdbPath = textBoxX2.Text;
                    IFeatureWorkspace        pFeatureWorkspace        = workspaceFactory.OpenFromFile(gdbPath, 0) as IFeatureWorkspace;
                    ISpatialReferenceFactory pSpatialReferenceFactory = new SpatialReferenceEnvironment();

                    //ISpatialReference pSpatialReference = new UnknownCoordinateSystemClass();
                    ISpatialReference pSpatialReference = ClsGDBDataCommon.CreateProjectedCoordinateSystem();
                    pSpatialReference.SetDomain(-8000000, 8000000, -800000, 8000000);
                    IFeatureDataset pFeatureDataset = pFeatureWorkspace.CreateFeatureDataset(textBoxX3.Text, pSpatialReference);
                    IFeatureClass   pFeatureclass   = CreatePointFeatureClass(pFeatureDataset, xml);
                    IFeatureClass   pFCLine         = CreatLineFC(pFeatureDataset, pFeatureclass);
                    if (pFeatureclass == null || pFCLine == null)
                    {
                        MessageBox.Show("数据生成失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }

                    IFeatureLayer pFPointLayer = new FeatureLayerClass();
                    pFPointLayer.FeatureClass = pFeatureclass;
                    pFPointLayer.Name         = textBoxX3.Text + "_Gmppoint";

                    IFeatureLayer pFLintLayer = new FeatureLayerClass();
                    pFLintLayer.FeatureClass = pFCLine;
                    pFLintLayer.Name         = textBoxX3.Text + "_GmpLine";

                    m_pMapCtl.AddLayer(pFLintLayer as ILayer, 0);
                    m_pMapCtl.AddLayer(pFPointLayer as ILayer, 0);
                    m_pMapCtl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);

                    if (cmbImpSymbol.Text != null && symFilePath != null)
                    {
                        ImpSymbolFromFile(symFilePath, pFPointLayer, pFLintLayer);
                    }


                    //MessageBox.Show("数据已经生成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
            }
        }
Beispiel #3
0
 private void btnPolygonDataset_Click(object sender, EventArgs e)
 {
     try
     {
         SaveFileDialog fbd = new SaveFileDialog();
         fbd.Title = "新建File Geodatabase";
         if (fbd.ShowDialog() == DialogResult.OK)
         {
             if (System.IO.Directory.Exists(fbd.FileName + ".gdb") == true)
             {
                 MessageBox.Show("GDB已存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 return;
             }
             //IWorkspaceFactory workspaceFactory = new FileGDBWorkspaceFactoryClass();
             //IWorkspaceName workspaceName = workspaceFactory.Create(System.IO.Path.GetDirectoryName(fbd.FileName), System.IO.Path.GetFileName(fbd.FileName), null, 0);
             ClsGDBDataCommon com = new ClsGDBDataCommon();
             com.Create_FileGDB(System.IO.Path.GetDirectoryName(fbd.FileName), System.IO.Path.GetFileName(fbd.FileName) + ".gdb");
             IWorkspace pws = com.OpenFromFileGDB(fbd.FileName + ".gdb");
             pFeatureDataset = creatdataset(pws, System.IO.Path.GetFileName(fbd.FileName), pMapControl.SpatialReference);
             creatfeatureclass(System.IO.Path.GetFileName(fbd.FileName));
             txtPolygonDataset.Text = fbd.FileName + ".gdb";
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         return;
     }
 }
Beispiel #4
0
        private void InitialColorRamp(esriSymbologyStyleClass styleClass)
        {
            if (m_pRasterRenderer is IRasterStretchColorRampRenderer)
            {
                //得到当前栅格拉伸渲染样式
                IRasterStretchColorRampRenderer rasterStrecthcRenderer = m_pRasterRenderer as IRasterStretchColorRampRenderer;

                //从文件打开渲染库
                string sInstall = ClsGDBDataCommon.GetParentPathofExe() + @"Resource\Style\ESRI.ServerStyle";
                axSymbologyControl1.LoadStyleFile(sInstall);
                axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassColorRamps;
                pSymbolClass = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassColorRamps);

                IStyleGalleryItem pStyleGalleryItem = new ServerStyleGalleryItem();
                pStyleGalleryItem.Item = rasterStrecthcRenderer.ColorRamp;
                pSymbolClass.AddItem(pStyleGalleryItem, 0);

                //将渲染库中所有渲染方式添加到列表中
                for (int i = 0; i < pSymbolClass.ItemCount; i++)
                {
                    stdole.IPictureDisp pPicture = pSymbolClass.PreviewItem(pSymbolClass.GetItem(i), cmbColorRamp.Width, cmbColorRamp.Height);
                    Image image = Image.FromHbitmap(new System.IntPtr(pPicture.Handle));
                    cmbColorRamp.Items.Add(image);
                }
                if (pSymbolClass.ItemCount > 0)
                {
                    pSymbolClass.SelectItem(0);
                }
                if (cmbColorRamp.Items.Count > 0)
                {
                    cmbColorRamp.SelectedIndex = 0;
                }
            }
        }
Beispiel #5
0
        public bool InitialZF_FileType(List <_ZF_FILETYPE> listFielType)
        {
            string strFile = ClsGDBDataCommon.GetParentPathofExe() + @"Resource\Configure\ZF_FileType.cfg";

            //读取文件
            try
            {
                //string strFileName = dlg.FileName;
                StreamReader sr      = new StreamReader(strFile, System.Text.Encoding.Default);
                string       strTemp = "";
                while (sr.Peek() >= 0)
                {
                    _ZF_FILETYPE fileType = new _ZF_FILETYPE();
                    strTemp = sr.ReadLine();
                    string[] strSplitLine;
                    char[]   c = new char[] { ' ' };
                    strSplitLine = strTemp.Split(c, StringSplitOptions.RemoveEmptyEntries);
                    if (strSplitLine.Length >= 3)
                    {
                        fileType.nCode          = int.Parse(strSplitLine[0]);
                        fileType.strFileType    = strSplitLine[1];
                        fileType.strDescription = strSplitLine[2];
                    }
                    listFielType.Add(fileType);
                }
                sr.Close();
            }
            catch (Exception ee)
            {
                return(false);
            }

            return(true);
        }
        private void btnImport_Click(object sender, EventArgs e)
        {
            ESRI.ArcGIS.SystemUI.ICommand command = new ControlsAddDataCommandClass();
            command.OnCreate(pMapControlSpacial);
            command.OnClick();
            //在此添加空间参考的详细信息
            if (pMapControlSpacial.Map != null)
            {
                for (int i = 0; i < pMapControlSpacial.Map.LayerCount; i++)
                {
                    ILayer pLayer = pMapControlSpacial.Map.get_Layer(i);

                    if (pLayer is IFeatureLayer)
                    {
                        IFeatureLayer     pFeatureLayer     = pLayer as IFeatureLayer;
                        IGeoDataset       pGeoDataset       = pFeatureLayer as IGeoDataset;
                        ISpatialReference pSpatialReference = pGeoDataset.SpatialReference;

                        richTextReference.Text = ClsGDBDataCommon.GetReferenceString(pSpatialReference);
                        pSpaReference          = pSpatialReference;
                    }
                    if (pLayer is IRasterLayer)
                    {
                        IRasterLayer      pRasterLayer      = pLayer as IRasterLayer;
                        IRaster           pRaster           = pRasterLayer.Raster;
                        IRasterProps      pRasterProps      = pRaster as IRasterProps;
                        ISpatialReference pSpatialReference = pRasterProps.SpatialReference;

                        richTextReference.Text = ClsGDBDataCommon.GetReferenceString(pSpatialReference);
                        pSpaReference          = pSpatialReference;
                    }
                }
                pMapControlSpacial.Map.ClearLayers();
            }
        }
Beispiel #7
0
        private void FrmFrameBorder_Load(object sender, EventArgs e)
        {
            //加载边框样式
            string EsriStylePathFram = ClsGDBDataCommon.GetParentPathofExe() + @"Resource\Style\ESRI.ServerStyle";

            axSymbologyCtlFrame.LoadStyleFile(EsriStylePathFram);
            axSymbologyCtlFrame.StyleClass = esriSymbologyStyleClass.esriStyleClassBorders;

            if (SymbolBorder != null)
            {
                pStyleGalleryItem.Item = SymbolBorder;

                ILineSymbol PLS = SymbolBorder.LineSymbol;
                this.SizeBorder.Text = PLS.Width.ToString();
                IColor pLineColor = PLS.Color;
                Color  pColor     = ColorTranslator.FromOle(pLineColor.RGB);
                colorBorder.SelectedColor = pColor;
                pLineSymbol = null;

                PreviewImage();
            }
            else
            {
                SetFeatureClassStyle(esriSymbologyStyleClass.esriStyleClassBorders);
            }
        }
Beispiel #8
0
        private void FrmFrameBackground_Load(object sender, EventArgs e)
        {
            //加载背景样式
            string EsriStylePathFram = ClsGDBDataCommon.GetParentPathofExe() + @"Resource\Style\ESRI.ServerStyle";

            axSymbologyCtlFrame.LoadStyleFile(EsriStylePathFram);
            axSymbologyCtlFrame.StyleClass = esriSymbologyStyleClass.esriStyleClassBackgrounds;
            if (SymbolBackground != null)
            {
                pStyleGalleryItem.Item = SymbolBackground;

                IFillSymbol pFS = SymbolBackground.FillSymbol;
                this.SizeBackgroundOutline.Text = pFS.Outline.Width.ToString();

                IColor pFillColor = pFS.Color;
                Color  pColorFill = ColorTranslator.FromOle(pFillColor.RGB);
                colorFill.SelectedColor = pColorFill;

                IColor pOutlineColor = pFS.Outline.Color;
                Color  pColorOutline = ColorTranslator.FromOle(pOutlineColor.RGB);
                colorOutline.SelectedColor = pColorOutline;
            }
            else
            {
                SetFeatureClassStyle(esriSymbologyStyleClass.esriStyleClassBackgrounds);
            }
        }
Beispiel #9
0
        //创建字体
        private void CreateTextSymbol()
        {
            if (pStyleGalleryItem == null)
            {
                MessageBox.Show("请选择指北针样式", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            pTextSymbol = pStyleGalleryItem.Item as ITextSymbol;

            //颜色
            if (FontColor.SelectedColor != null)
            {
                pTextSymbol.Color = ClsGDBDataCommon.ColorToIColor(FontColor.SelectedColor);;
            }

            //大小
            string pFontString = double.Parse(FontSize.Text).ToString();

            pFont.Size = decimal.Parse(pFontString);

            //字体、
            pFont.Name = this.cmbBoxFontName.Text;

            //风格
            if (toolBtnBold.Checked == true)
            {
                pFont.Bold = true;
            }
            else
            {
                pFont.Bold = false;
            }
            if (toolBtnIntend.Checked == true)
            {
                pFont.Italic = true;
            }
            else
            {
                pFont.Italic = false;
            }
            if (toolBtnUnderline.Checked == true)
            {
                pFont.Underline = true;
            }
            else
            {
                pFont.Underline = false;
            }
            if (toolBtnStrikethrough.Checked == true)
            {
                pFont.Strikethrough = true;
            }
            else
            {
                pFont.Strikethrough = false;
            }

            pTextSymbol.Font = pFont;
        }
Beispiel #10
0
        private void buttonX_ok_Click(object sender, EventArgs e)
        {
            if (Convert.ToInt32(textBoxX4.Text) > 10)
            {
                MessageBox.Show("对齐参考点距离超过10米,精度低于预期,不能用于对齐!");
                return;
            }
            Thread.Sleep(4000);
            ClsGDBDataCommon processDataCommon = new ClsGDBDataCommon();
            string           strInputPath      = System.IO.Path.GetDirectoryName(textBoxX2.Text);
            string           strInputName      = System.IO.Path.GetFileName(textBoxX2.Text);

            #region 读取SHP文件
            IWorkspace        pWorkspace        = processDataCommon.OpenFromShapefile(strInputPath);
            IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace;
            IFeatureClass     pInputFC          = pFeatureWorkspace.OpenFeatureClass(strInputName);
            #endregion

            IFeatureLayer pFeatureLayer = new FeatureLayerClass();
            pFeatureLayer.FeatureClass = pInputFC;
            pFeatureLayer.Name         = strInputName;
            m_pMapCtl.AddLayer(pFeatureLayer as ILayer, 0);
            m_pMapCtl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);

            this.Close();
        }
        private void FrmCoordinateSystem_Load(object sender, EventArgs e)
        {
            switch (startPosition)
            {
            case "startFromMap":
                DirectoryInfo CoordDirInfo = new DirectoryInfo(ClsGDBDataCommon.GetParentPathofExe() + @"Resource\Coordinate Systems");
                LoadDirectories(advTreeCoord.Nodes[0], CoordDirInfo);

                richTextReference.Text = ClsGDBDataCommon.GetReferenceString(pMapControl.SpatialReference);
                IEngineEditor pEngineEdit = new EngineEditorClass();
                if (pEngineEdit.Map == pMapControl.Map)
                {
                    advTreeCoord.Enabled = false;
                    MessageBox.Show("该图层处在编辑状态不能修改坐标系统", "提示", MessageBoxButtons.YesNo);
                }
                break;

            case "startFromLayer":
                DirectoryInfo CoordDirInfoLayer = new DirectoryInfo(ClsGDBDataCommon.GetParentPathofExe() + @"Resource\Coordinate Systems");
                LoadDirectories(advTreeCoord.Nodes[0], CoordDirInfoLayer);
                IGeoDataset       geoDataset = pLayer as IGeoDataset;
                ISpatialReference reference  = geoDataset.SpatialReference;

                richTextReference.Text = ClsGDBDataCommon.GetReferenceString(reference);
                break;
            }
        }
        private void advTreeCoord_NodeClick(object sender, TreeNodeMouseEventArgs e)
        {
            if (e.Node.Text.Contains(".prj") == true)
            {
                string fileFullPath = "";
                string fileFullName = e.Node.Text;
                int    depthIndex   = e.Node.Level;
                Node   curnode      = new Node();
                curnode = e.Node;
                for (int i = depthIndex; i > 1; i--)
                {
                    fileFullName = curnode.Parent.Text + "\\" + fileFullName;
                    curnode      = curnode.Parent;
                }
                fileFullPath = ClsGDBDataCommon.GetParentPathofExe() + @"Resource\Coordinate Systems\" + fileFullName;

                ISpatialReferenceFactory pSpatialReferenceFactory = new SpatialReferenceEnvironmentClass();
                try
                {
                    ISpatialReference pSpatialReference = pSpatialReferenceFactory.CreateESRISpatialReferenceFromPRJFile(fileFullPath);
                    if (pSpatialReference == null)
                    {
                        return;
                    }
                    pSpaReference = pSpatialReference;

                    richTextReference.Text = ClsGDBDataCommon.GetReferenceString(pSpatialReference);
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message);
                }
            }
        }
        private void btnSelPrjFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter = "PRJ文件(*.prj)|*.prj";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                ISpatialReferenceFactory pSpatialReferenceFactory = new SpatialReferenceEnvironmentClass();
                try
                {
                    ISpatialReference pSpatialReference = pSpatialReferenceFactory.CreateESRISpatialReferenceFromPRJFile(dlg.FileName);
                    if (pSpatialReference == null)
                    {
                        return;
                    }
                    pSpaReference = pSpatialReference;

                    richTextReference.Text = ClsGDBDataCommon.GetReferenceString(pSpaReference);
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message);
                }
            }
        }
Beispiel #14
0
        //样式选择
        private void axSymbologyControl_OnItemSelected(object sender, ISymbologyControlEvents_OnItemSelectedEvent e)
        {
            //选择样式
            pStyleGalleryItem = (IStyleGalleryItem)e.styleGalleryItem;
            //将选择的样式与设计的样式大小、颜色等属性结合
            if (axSymbologyControl.StyleClass == esriSymbologyStyleClass.esriStyleClassMarkerSymbols)
            {
                IMarkerSymbol pMarkerSymbol = pStyleGalleryItem.Item as IMarkerSymbol;
                double        pMarkerSize   = pMarkerSymbol.Size;
                PointSize.Text = pMarkerSize.ToString();
                double pMarkerAngle = pMarkerSymbol.Angle;
                PointAngle.Text          = pMarkerAngle.ToString();
                colorPoint.SelectedColor = ClsGDBDataCommon.IColorToColor(pMarkerSymbol.Color);
            }
            else if (axSymbologyControl.StyleClass == esriSymbologyStyleClass.esriStyleClassLineSymbols)
            {
                ILineSymbol pLineSymbol = pStyleGalleryItem.Item as ILineSymbol;
                double      pLineWidth  = pLineSymbol.Width;
                LineSize.Text = pLineWidth.ToString();

                colorLine.SelectedColor = ClsGDBDataCommon.IColorToColor(pLineSymbol.Color);
            }
            else if (axSymbologyControl.StyleClass == esriSymbologyStyleClass.esriStyleClassFillSymbols)
            {
                IFillSymbol pFillSymbol = pStyleGalleryItem.Item as IFillSymbol;

                PolygonSize.Text           = pFillSymbol.Outline.Width.ToString();
                colorPolygon.SelectedColor = ClsGDBDataCommon.IColorToColor(pFillSymbol.Color);
                colorOutLine.SelectedColor = ClsGDBDataCommon.IColorToColor(pFillSymbol.Outline.Color);
            }
            PreviewImage();
        }
Beispiel #15
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (m_pPageLayoutCtl == null)
            {
                return;
            }

            string strFullpath = txtFolder.Text;

            if (strFullpath[strFullpath.Length - 1] != System.IO.Path.DirectorySeparatorChar)
            {
                strFullpath += System.IO.Path.DirectorySeparatorChar;
            }

            string strDocName = CreateMxdFolderAndGDB(strFullpath, m_pPageLayoutCtl.DocumentFilename);

            string strFullGdbName = strFullpath + strDocName + ".gdb";
            string strFullDocName = strFullpath + strDocName + ".mxd";
            //另存地图文档
            ClsGDBDataCommon cls = new ClsGDBDataCommon();

            m_pMapDoc = cls.SaveAsDocument(m_pPageLayoutCtl, strFullDocName);
            //n
            if (ExportLayers(m_pMapDoc, strFullGdbName, radioLayer.Checked))
            {
                m_pMapDoc.Save(true, false);
                m_strDocNameNew = m_pMapDoc.DocumentFilename;
                m_pMapDoc.Close();

                MessageBox.Show("导出成功!");
            }
        }
Beispiel #16
0
        private void FrmSymbolStyle_Load(object sender, EventArgs e)
        {
            //遍历文件
            DirectoryInfo theFolder = new DirectoryInfo(ClsGDBDataCommon.GetParentPathofExe() + @"Resource\Style\");

            FileInfo[] fileInfo = theFolder.GetFiles();
            //样式数量
            int StyleNumber = 0;

            foreach (FileInfo NextFile in fileInfo)  //遍历文件获取数量
            {
                StyleNumber++;
            }
            DevComponents.DotNetBar.BaseItem[] BaseItem = new DevComponents.DotNetBar.BaseItem[StyleNumber];
            int N = 0;

            foreach (FileInfo NextFile in fileInfo)  //遍历文件加载名称
            {
                DevComponents.DotNetBar.CheckBoxItem CheckBox = new DevComponents.DotNetBar.CheckBoxItem();
                CheckBox.Name = NextFile.Name;
                CheckBox.Text = NextFile.Name;
                for (int i = 0; i < SelectStylePath.Length; i++)
                {
                    string FileName = System.IO.Path.GetFileName(SelectStylePath[i]);
                    if (FileName == CheckBox.Text && FileName != null)
                    {
                        CheckBox.Checked = true;
                    }
                }
                BaseItem[N] = CheckBox;
                N++;
            }
            this.itemPanelStyleList.Items.AddRange(BaseItem);
            this.itemPanelStyleList.Refresh();
        }
Beispiel #17
0
        private void FrmScaleBar_Load(object sender, EventArgs e)
        {
            try
            {
                //添加比例尺样式
                string EsriStylePath = ClsGDBDataCommon.GetParentPathofExe() + @"Resource\Style\ESRI.ServerStyle";
                axSymbologyControl.LoadStyleFile(EsriStylePath);

                axSymbologyControl.StyleClass = StyleClass;

                if (StyleClass == esriSymbologyStyleClass.esriStyleClassScaleBars)
                {
                    this.Text = "图形比例尺";
                    SetFeatureClassStyle(esriSymbologyStyleClass.esriStyleClassScaleBars, 0);
                }
                else if (StyleClass == esriSymbologyStyleClass.esriStyleClassScaleTexts)
                {
                    this.Text = "文字比例尺";
                    SetFeatureClassStyle(esriSymbologyStyleClass.esriStyleClassScaleTexts, 1);
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #18
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                string szFilename = txtXmlFilename.Text;
                if (!string.IsNullOrEmpty(szFilename))
                {
                    File.Delete(szFilename);
                }
                else
                {
                    DateTime dt         = DateTime.Now;
                    string   szAppendix = "_" + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + "_" + dt.Hour.ToString() + dt.Minute.ToString() + dt.Second.ToString();
                    szFilename = ClsGDBDataCommon.GetParentPathofExe() + @"Resource\ModelInfo" + szAppendix + ".xml";
                }

                writeModelInfoToXml(szFilename);

                //更新图层
                if (m_pRasterLayer != null)
                {
                    ClsAddModelToTerrain pAddModelToTerrain = new ClsAddModelToTerrain();
                    pAddModelToTerrain.addModelToTerrain(szFilename, m_pRasterLayer);
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public IFeatureClass CreateShapeFile(DataSet ds, string strOutShpName, ISpatialReference pSRF)
        {
            try
            {
                DirectoryInfo    di         = new DirectoryInfo(strOutShpName);
                string           filefolder = di.Parent.FullName;
                ClsGDBDataCommon cdc        = new ClsGDBDataCommon();
                //cdc.OpenFromShapefile(filefolder);
                IFields     pFields     = new FieldsClass();
                IFieldsEdit pFieldsEdit = (IFieldsEdit)pFields;

                //设置字段
                IField     pField     = new FieldClass();
                IFieldEdit pFieldEdit = (IFieldEdit)pField;

                //创建类型为几何类型的字段
                IGeometryDef     pGeoDef     = new GeometryDefClass();
                IGeometryDefEdit pGeoDefEdit = (IGeometryDefEdit)pGeoDef;
                pGeoDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint;

                pGeoDefEdit.HasM_2             = false;
                pGeoDefEdit.HasZ_2             = false;
                pGeoDefEdit.SpatialReference_2 = pSRF;

                pFieldEdit.Name_2        = "SHAPE";
                pFieldEdit.Type_2        = esriFieldType.esriFieldTypeGeometry;
                pFieldEdit.GeometryDef_2 = pGeoDef;
                //pFieldEdit.IsNullable_2 = true;
                //pFieldEdit.Required_2 = true;
                pFieldsEdit.AddField(pField);

                for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
                {
                    pField                  = new FieldClass();
                    pFieldEdit              = (IFieldEdit)pField;
                    pFieldEdit.Name_2       = ds.Tables[0].Columns[i].ColumnName;
                    pFieldEdit.Type_2       = esriFieldType.esriFieldTypeString;
                    pFieldEdit.IsNullable_2 = true;
                    pFieldsEdit.AddField(pField);
                }

                ClsGDBDataCommon comm     = new ClsGDBDataCommon();
                IWorkspace       inmemWor = comm.OpenFromShapefile(filefolder);
                // ifeatureworkspacee
                IFeatureWorkspace pFeatureWorkspace = inmemWor as IFeatureWorkspace;
                IFeatureClass     pFeatureClass     = pFeatureWorkspace.CreateFeatureClass(di.Name, pFields, null, null, esriFeatureType.esriFTSimple, "SHAPE", "");

                return(pFeatureClass);
                //IFeatureLayer pFeatureLayer = new FeatureLayerClass();
                //pFeatureLayer.FeatureClass = pFeatureClass;
                //pFeatureLayer.Name = System.IO.Path.GetFileNameWithoutExtension(di.Name);
                //m_mapControl.AddLayer(pFeatureLayer as ILayer, 0);
                //m_mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            }
            catch (SystemException ee)
            {
                MessageBox.Show(ee.Message);
                return(null);
            }
        }
Beispiel #20
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            IPageLayoutControl3 pPageLayoutControl = null;

            if (m_hookHelper.Hook is IToolbarControl)
            {
                pPageLayoutControl = (IPageLayoutControl3)((IToolbarControl)m_hookHelper.Hook).Buddy;
            }
            //In case the container is MapControl
            else if (m_hookHelper.Hook is IPageLayoutControl3)
            {
                pPageLayoutControl = (IPageLayoutControl3)m_hookHelper.Hook;
            }
            else
            {
                MessageBox.Show("µ±Ç°½çÃæ±ØÐëÊÇPageLayoutControl½çÃæ!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            SaveFileDialog dlgFile = new SaveFileDialog();//ÒÔ¶Ô»°¿òÑ¡ÔñÎĵµÂ·¾¶

            dlgFile.Title  = "Áí´æµØͼÎĵµ";
            dlgFile.Filter = "Map Documents(*.mxd)|*.mxd";
            string sFilePath = string.Empty;

            if (dlgFile.ShowDialog() == DialogResult.OK)
            {
                sFilePath = dlgFile.FileName;
                ClsGDBDataCommon cls = new ClsGDBDataCommon();
                m_pDoc = cls.SaveAsDocument(pPageLayoutControl, sFilePath);
            }
        }
Beispiel #21
0
        private IRasterDataset CopyRasterToWorkspace(IMap map, ILayer layer, IWorkspace wksDst, bool bLayerSpatial)
        {
            if (layer is IRasterLayer)
            {
                IRasterLayer rasterLayer = layer as IRasterLayer;
                if (rasterLayer.Raster == null)
                {
                    return(null);
                }

                IRaster rasterSrc = rasterLayer.Raster;
                //设置空间参考
                ISpatialReference spatialRef;
                if (bLayerSpatial)
                {
                    IGeoDataset pGeo = (IGeoDataset)rasterLayer;
                    spatialRef = pGeo.SpatialReference;
                }
                else
                {
                    spatialRef = map.SpatialReference;
                }

                ClsGDBDataCommon cls = new ClsGDBDataCommon();
                return(cls.ExportRasterToWorkspace(rasterSrc, wksDst, layer.Name, spatialRef));
            }
            return(null);
        }
Beispiel #22
0
        private void FrmSymbol_Load(object sender, EventArgs e)
        {
            //几个设计小界面显示位置
            this.gPanelPoint.Location   = new System.Drawing.Point(256, 151);
            this.gPanelLine.Location    = this.gPanelPoint.Location;
            this.gPanelPolygon.Location = this.gPanelPoint.Location;

            //Get the ArcGIS install location
            string EsriStylePath = ClsGDBDataCommon.GetParentPathofExe() + @"Resource\Style\ESRI.ServerStyle";

            axSymbologyControl.LoadStyleFile(EsriStylePath);

            axSymbologyControl.StyleClass = pStyleClass;

            //判读那个设计小界面显示
            if (pStyleClass == esriSymbologyStyleClass.esriStyleClassMarkerSymbols)
            {
                gPanelPoint.Visible   = true;
                gPanelLine.Visible    = false;
                gPanelPolygon.Visible = false;
            }
            else if (pStyleClass == esriSymbologyStyleClass.esriStyleClassLineSymbols)
            {
                gPanelPoint.Visible   = false;
                gPanelLine.Visible    = true;
                gPanelPolygon.Visible = false;
            }
            else if (pStyleClass == esriSymbologyStyleClass.esriStyleClassFillSymbols)
            {
                gPanelPoint.Visible   = false;
                gPanelLine.Visible    = false;
                gPanelPolygon.Visible = true;
            }
        }
Beispiel #23
0
        private string CreateMxdFolderAndGDB(string fulPath, string docName)
        {
            //在指定文件夹中创建与地图文档同名的GDB,如果地图文档名称为空,创建与文件夹同名的GDB
            DirectoryInfo path = new DirectoryInfo(fulPath);

            if (path == null)
            {
                return(string.Empty);
            }
            if (!path.Exists)
            {
                path.Create();
            }

            if (string.IsNullOrEmpty(docName))
            {
                docName = path.Name;
            }
            else
            {
                docName = System.IO.Path.GetFileNameWithoutExtension(docName);
            }

            //创建GDB
            ClsGDBDataCommon cls = new ClsGDBDataCommon();

            if (!cls.Create_FileGDB(path.FullName, docName))
            {
                MessageBox.Show("创建数据库失败!");
                return(string.Empty);
            }

            return(docName);
        }
        private void btnClear_Click(object sender, EventArgs e)
        {
            ISpatialReference SpaReference = new UnknownCoordinateSystemClass();

            pSpaReference          = SpaReference;
            richTextReference.Text = ClsGDBDataCommon.GetReferenceString(SpaReference);
        }
Beispiel #25
0
        private void FrmEditLine_Load(object sender, EventArgs e)
        {
            IMultiLayerLineSymbol pMultiLayerLineSymbol = pStyleGalleryItem.Item as IMultiLayerLineSymbol;

            colorSimpleLine.SelectedColor = ClsGDBDataCommon.IColorToColor(pMultiLayerLineSymbol.get_Layer(0).Color);
            PreviewImage();
            addListBoxItem();
        }
 //颜色
 private void colorNorthArrow_SelectedColorChanged(object sender, EventArgs e)
 {
     if (m_pNorthArrow != null)
     {
         m_pNorthArrow.Color = ClsGDBDataCommon.ColorToIColor(colorNorthArrow.SelectedColor);
         m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
     }
 }
Beispiel #27
0
        private void FrmLegendStyle_Load(object sender, EventArgs e)
        {
            //加载图例样式
            string EsriStylePathFram = ClsGDBDataCommon.GetParentPathofExe() + @"Resource\Style\ESRI.ServerStyle";

            axSymbologyCtlLegendItem.LoadStyleFile(EsriStylePathFram);
            axSymbologyCtlLegendItem.StyleClass = esriSymbologyStyleClass.esriStyleClassLegendItems;
        }
Beispiel #28
0
        //创建点状线
        private IMarkerLineSymbol CreateMarkerLineSymbol()
        {
            IMarkerLineSymbol pMarkerLS = new MarkerLineSymbol();

            //样式
            if (pMarkerSymbol != null)
            {
                pMarkerLS.MarkerSymbol = pMarkerSymbol;
            }

            ICartographicLineSymbol pCartographicLS = pMarkerLS as ICartographicLineSymbol;

            //颜色
            if (colorCartographicLine.SelectedColor != Color.Empty)
            {
                pCartographicLS.Color = ClsGDBDataCommon.ColorToIColor(colorCartographicLine.SelectedColor);
            }
            else
            {
                pCartographicLS.Color = ClsGDBDataCommon.ColorToIColor(Color.Black);
                colorCartographicLine.SelectedColor = Color.Black;
            }
            //宽度
            pCartographicLS.Width = double.Parse(widthCartographicLine.Text);

            //端点样式
            if (rbCatButt.Checked == true)
            {
                pCartographicLS.Cap = esriLineCapStyle.esriLCSButt;
            }
            else if (rbCatRoundC.Checked == true)
            {
                pCartographicLS.Cap = esriLineCapStyle.esriLCSRound;
            }
            else if (rbCatSquare.Checked == true)
            {
                pCartographicLS.Cap = esriLineCapStyle.esriLCSSquare;
            }

            //节点样式
            if (rbCatMitre.Checked == true)
            {
                pCartographicLS.Join = esriLineJoinStyle.esriLJSMitre;
            }
            else if (rbCatRoundJ.Checked == true)
            {
                pCartographicLS.Join = esriLineJoinStyle.esriLJSRound;
            }
            else if (rbCatBevel.Checked == true)
            {
                pCartographicLS.Join = esriLineJoinStyle.esriLJSBevel;
            }

            //端点箭头样式
            ILineDecorationElement pLineDecorationElement = new SimpleLineDecorationElement();

            return(pMarkerLS);
        }
Beispiel #29
0
        private void comboBoxEx1_SelectedIndexChanged(object sender, EventArgs e)
        {
            ILayer pLayer = ClsGDBDataCommon.GetLayerFromName(m_pMapCtl.Map, comboBoxEx1.Text);

            if (pLayer is IFeatureLayer)
            {
                IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
                pPointFeatureclass = pFeatureLayer.FeatureClass;
            }
        }
Beispiel #30
0
        private void comboBoxEx2_SelectedIndexChanged(object sender, EventArgs e)
        {
            ILayer pLayer = ClsGDBDataCommon.GetLayerFromName(m_pMapCtl.Map, comboBoxEx2.Text);

            if (pLayer is IRasterLayer)
            {
                IRasterLayer pFeatureLayer = pLayer as IRasterLayer;
                pRaster = pFeatureLayer.Raster;
            }
        }