예제 #1
0
 //private void GetLongLat(float jing, float wei, out float Long, float lat)
 //{
 //}
 private void GotoXY_Load(object sender, EventArgs e)
 {
     activeview = pAxMapControl.Map as IActiveView;
     map = activeview.FocusMap;
     pScreenDisplay = activeview.ScreenDisplay;
     pGraphicsContainer = map as IGraphicsContainer;
     IGraphicsContainerSelect pGraphconSel = map as IGraphicsContainerSelect;
 }
예제 #2
0
 public MainForm()
 {
     InitializeComponent();
     m_ipActiveView = axMapControl1.ActiveView;
     m_ipMap = m_ipActiveView.FocusMap;
     clicked = false;
     pGC = m_ipMap as IGraphicsContainer;
 }
예제 #3
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            m_ActiveView = m_hookHelper.ActiveView;
            m_Map        = m_hookHelper.FocusMap;
            IScreenDisplay    pScreenDisplay  = m_ActiveView.ScreenDisplay;
            IRubberBand       pRubberPolyline = new RubberLineClass();
            ISimpleLineSymbol pLineSymbol     = new SimpleLineSymbolClass();

            pLineSymbol.Color = getRGB(255, 255, 0);
            IPolyline pPolyline = pRubberPolyline.TrackNew(pScreenDisplay, (ISymbol)pLineSymbol) as IPolyline;

            pLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
            pLineSymbol.Color = getRGB(0, 255, 255);
            ILineElement pPolylineEle = new LineElementClass();

            pPolylineEle.Symbol = pLineSymbol;
            IElement pEle = pPolylineEle as IElement;

            pEle.Geometry = pPolyline;
            IGraphicsContainer pGraphicsContainer = m_Map as IGraphicsContainer;

            pGraphicsContainer.AddElement(pEle, 0);
            m_ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
예제 #4
0
        /// <summary>
        /// 删除已存在格网
        /// </summary>
        /// <param name="pActiveView"></param>
        public static void DeleteExistMapGrid(IActiveView pActiveView)
        {
            IGraphicsContainer graphicsContainer = pActiveView as IGraphicsContainer;

            if (graphicsContainer == null)
            {
                return;
            }
            IMap          pMap         = pActiveView.FocusMap;
            IFrameElement frameElement = graphicsContainer.FindFrame(pMap);
            IMapFrame     mapFrame     = frameElement as IMapFrame;
            IMapGrids     mapGrids     = mapFrame as IMapGrids;

            if (mapGrids == null)
            {
                return;
            }
            if (mapGrids.MapGridCount > 0)
            {
                IMapGrid pMapGrid = mapGrids.MapGrid[0];
                mapGrids.DeleteMapGrid(pMapGrid);
            }
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null);
        }
예제 #5
0
        private bool addText(ITextElement ppTextElement, IGeometry geo)
        {
            IPageLayout        pPageLayout        = mainPage.PageLayout;
            IGraphicsContainer pGraphicsContainer = mainPage.PageLayout as IGraphicsContainer;
            IEnvelope          pEnv     = new EnvelopeClass();
            IElement           pElement = ppTextElement as IElement;

            pEnv = this.mainPage.ActiveView.Extent;

            if (geo == null)
            {
                IPoint pPoint = new PointClass();
                pPoint.PutCoords((pEnv.XMin + pEnv.YMax) / 2, (pEnv.YMin + pEnv.YMax) / 2);
                pElement.Geometry = pPoint;
            }
            else
            {
                pElement.Geometry = geo;
            }

            pGraphicsContainer.AddElement(pElement, 0);
            mainPage.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            return(true);
        }
예제 #6
0
        //在鹰眼地图上面画矩形框
        private void DrawRectangle(IEnvelope pEnvelope)
        {
            //在绘制前,清除鹰眼中之前绘制的矩形框
            IGraphicsContainer pGraphicsContainer = eagleEyeMapControl.Map as IGraphicsContainer;
            IActiveView        pActiveView        = pGraphicsContainer as IActiveView;

            pGraphicsContainer.DeleteAllElements();
            //得到当前视图范围
            IRectangleElement pRectangleElement = new RectangleElementClass();
            IElement          pElement          = pRectangleElement as IElement;

            pElement.Geometry = pEnvelope;
            //设置矩形框(实质为中间透明度面)
            IRgbColor pColor = new RgbColorClass();

            pColor = GetRgbColor(30, 144, 255);
            pColor.Transparency = 255;
            ILineSymbol pOutLine = new SimpleLineSymbolClass();

            pOutLine.Width = 2;
            pOutLine.Color = pColor;

            IFillSymbol pFillSymbol = new SimpleFillSymbolClass();

            pColor = new RgbColorClass();
            pColor.Transparency = 0;
            pFillSymbol.Color   = pColor;
            pFillSymbol.Outline = pOutLine;
            //向鹰眼中添加矩形框
            IFillShapeElement pFillShapeElement = pElement as IFillShapeElement;

            pFillShapeElement.Symbol = pFillSymbol;
            pGraphicsContainer.AddElement((IElement)pFillShapeElement, 0);
            //刷新
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
예제 #7
0
        private void insertLegendToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IGraphicsContainer graphicsContainer =
                m_controlsSynchronizer.PageLayoutControl.GraphicsContainer;
            IMapFrame mapFrame = (IMapFrame)graphicsContainer.FindFrame
                                     (m_controlsSynchronizer.PageLayoutControl.ActiveView.FocusMap);

            if (mapFrame == null)
            {
                return;
            }
            UID uID = new UIDClass();

            uID.Value = "esriCarto.Legend";
            IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uID, null);

            if (mapSurroundFrame == null)
            {
                return;
            }
            if (mapSurroundFrame.MapSurround == null)
            {
                return;
            }
            mapSurroundFrame.MapSurround.Name = "Legend";
            IEnvelope envelope = new Envelope() as IEnvelope;

            envelope.PutCoords(1, 1, 3.4, 2.4);
            IElement element = (IElement)mapSurroundFrame;

            element.Geometry = envelope;
            m_controlsSynchronizer.PageLayoutControl.AddElement(element,
                                                                Type.Missing, Type.Missing, "Legend", 0);
            m_controlsSynchronizer.PageLayoutControl.ActiveView.
            PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
예제 #8
0
        private void axMapControl1_OnExtentUpdated(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnExtentUpdatedEvent e)
        {
            IEnvelope          envelope          = (IEnvelope)e.newEnvelope;
            IGraphicsContainer graphicsContainer = axMapControl2.Map as IGraphicsContainer;
            IActiveView        activeView        = graphicsContainer as IActiveView;

            graphicsContainer.DeleteAllElements();
            IElement element = new RectangleElement();

            element.Geometry = envelope;
            ILineSymbol outLineSymbol = new SimpleLineSymbol();

            outLineSymbol.Width = 2;
            outLineSymbol.Color = GetColor(0, 150, 200, 230);
            IFillSymbol fillSymbol = new SimpleFillSymbol();

            fillSymbol.Color   = GetColor(9, 0, 0, 0);
            fillSymbol.Outline = outLineSymbol;
            IFillShapeElement fillShapeElement = element as IFillShapeElement;

            fillShapeElement.Symbol = fillSymbol;
            graphicsContainer.AddElement((IElement)fillShapeElement, 0);
            activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
예제 #9
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            m_ActiveView = m_hookHelper.ActiveView;
            m_Map        = m_hookHelper.FocusMap;
            IScreenDisplay    pScreenDisplay = m_ActiveView.ScreenDisplay;
            IRubberBand       pRubberPolygon = new RubberPolygonClass();
            ISimpleFillSymbol pFillSymbol    = new SimpleFillSymbolClass();

            pFillSymbol.Color = getRGB(255, 255, 0);
            IPolygon pPolygon = pRubberPolygon.TrackNew(pScreenDisplay, (ISymbol)pFillSymbol) as IPolygon;

            pFillSymbol.Style = esriSimpleFillStyle.esriSFSDiagonalCross;
            pFillSymbol.Color = getRGB(0, 0, 255);
            IFillShapeElement pPolygonEle = new PolygonElementClass();

            pPolygonEle.Symbol = pFillSymbol;
            IElement pEle = pPolygonEle as IElement;

            pEle.Geometry = pPolygon;
            IGraphicsContainer pGraphicsContainer = m_Map as IGraphicsContainer;

            pGraphicsContainer.AddElement(pEle, 0);
            m_ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
예제 #10
0
파일: EagleEyeForm.cs 프로젝트: siszoey/GT
        private void MainMapControl_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e)
        {
            IEnvelope          vEnvelope          = (IEnvelope)e.newEnvelope;
            IGraphicsContainer vGraphicsContainer = axMapControl_EagleEye.Map as IGraphicsContainer;
            IActiveView        vActiveView        = vGraphicsContainer as IActiveView;

            vGraphicsContainer.DeleteAllElements();
            IElement vElement = new RectangleElementClass();

            vElement.Geometry = vEnvelope;
            ILineSymbol vOutLineSymbol = new SimpleLineSymbolClass();

            vOutLineSymbol.Width = 2;
            vOutLineSymbol.Color = getColor(255, 0, 0, 255);
            IFillSymbol vFileSymbol = new SimpleFillSymbolClass();

            vFileSymbol.Color   = getColor(9, 0, 0, 0);
            vFileSymbol.Outline = vOutLineSymbol;
            IFillShapeElement vFillShapeElement = vElement as IFillShapeElement;

            vFillShapeElement.Symbol = vFileSymbol;
            vGraphicsContainer.AddElement((IElement)vFillShapeElement, 0);
            vActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, null, null);
        }
예제 #11
0
        private IGraphicsContainerSelect GetSelection()
        {
            IGraphicsContainerSelect result;

            try
            {
                IActiveView        activeView        = this._context.ActiveView;
                IGraphicsContainer graphicsContainer = activeView.GraphicsContainer;
                if (graphicsContainer == null)
                {
                    result = null;
                    return(result);
                }
                //IViewManager viewManager = activeView as IViewManager;
                //ISelection arg_2E_0 = viewManager.ElementSelection;
                result = (graphicsContainer as IGraphicsContainerSelect);
                return(result);
            }
            catch
            {
            }
            result = null;
            return(result);
        }
예제 #12
0
        private void DrawLine(IPolyline line)
        {
            ILineElement lineElement;

            lineElement = new LineElementClass();
            IElement          element;
            ISimpleLineSymbol pSLnSym;
            IRgbColor         pRGB;

            pRGB               = new RgbColorClass();
            pRGB.Red           = 0;
            pRGB.Green         = 0;
            pRGB.Blue          = 0;
            pSLnSym            = new SimpleLineSymbolClass();
            pSLnSym.Color      = pRGB;
            pSLnSym.Style      = ESRI.ArcGIS.Display.esriSimpleLineStyle.esriSLSSolid;
            lineElement.Symbol = pSLnSym;
            element            = lineElement as IElement;
            element.Geometry   = line;
            IGraphicsContainer graphicsContainer = this.m_pMapControl.Map as IGraphicsContainer;

            graphicsContainer.AddElement(element, 0);
            this.m_pMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
        }
예제 #13
0
        private void CreateResultElements()
        {
            IGeometryCollection geometryCollection = new GeometryBag() as IGeometryCollection;

            for (int i = 0; i < this._networkInfo.arrayList_1.Count; i++)
            {
                object   missing = Type.Missing;
                IFeature feature = (IFeature)this._networkInfo.arrayList_1[i];
                geometryCollection.AddGeometry(feature.ShapeCopy, ref missing, ref missing);
            }
            if (this._networkInfo.arrayList_1.Count > 0)
            {
                IRgbColor rgbColor = new RgbColor();
                rgbColor.Red   = (255);
                rgbColor.Green = (0);
                rgbColor.Blue  = (255);
                IGraphicsContainer graphicsContainer = (IGraphicsContainer)m_iApp.ActiveView;
                for (int j = 0; j < geometryCollection.GeometryCount; j++)
                {
                    ILineElement lineElement = new LineElement() as ILineElement;
                    IElement     element     = (IElement)lineElement;
                    element.Geometry = (geometryCollection.get_Geometry(j));
                    ILineElement      arg_F5_0 = lineElement;
                    ISimpleLineSymbol simpleLineSymbolClass = new SimpleLineSymbol();
                    simpleLineSymbolClass.Color = (rgbColor);
                    simpleLineSymbolClass.Width = (10.0);
                    simpleLineSymbolClass.Style = (0);
                    arg_F5_0.Symbol             = (simpleLineSymbolClass);
                    graphicsContainer.AddElement(element, 0);
                }
                IEnvelope envelope = ((IGeometry)geometryCollection).Envelope;
                envelope.Expand(1.2, 1.2, true);
                m_iApp.ActiveView.Extent = (envelope);
                m_iApp.ActiveView.Refresh();
            }
        }
예제 #14
0
        private void axMapControl1_OnExtentUpdated(object sender,
                                                   IMapControlEvents2_OnExtentUpdatedEvent e)
        {
            IEnvelope          pEnv = e.newEnvelope as IEnvelope;
            IGraphicsContainer pGraphicsContainer = poverView.axMapControl1.Map
                                                    as IGraphicsContainer;
            IActiveView pActiveView = pGraphicsContainer as IActiveView;

            pGraphicsContainer.DeleteAllElements();
            IRectangleElement pRectangleEle = new RectangleElementClass();
            IElement          pEle          = pRectangleEle as IElement;

            pEle.Geometry = pEnv;
            IRgbColor pColor = new RgbColorClass();

            pColor.RGB          = 255;
            pColor.Transparency = 255;
            ILineSymbol pOutline = new SimpleLineSymbolClass();

            pOutline.Width      = 1;
            pOutline.Color      = pColor;
            pColor              = new RgbColorClass();
            pColor.RGB          = 255;
            pColor.Transparency = 0;
            IFillSymbol pFillSymbol;

            pFillSymbol         = new SimpleFillSymbolClass();
            pFillSymbol.Color   = pColor;
            pFillSymbol.Outline = pOutline;
            IFillShapeElement pFillShapeEle = pEle as IFillShapeElement;

            pFillShapeEle.Symbol = pFillSymbol;
            pEle = pFillShapeEle as IElement;
            pGraphicsContainer.AddElement(pEle, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
예제 #15
0
        public void Undo()
        {
            this.ienumElement_0.Reset();
            IElement                 element                 = this.ienumElement_0.Next();
            IGraphicsContainer       graphicsContainer       = this.iactiveView_0.GraphicsContainer;
            IGraphicsContainerSelect graphicsContainerSelect = graphicsContainer as IGraphicsContainerSelect;

            graphicsContainerSelect.UnselectAllElements();
            while (element != null)
            {
                if (element is IGroupElement)
                {
                    IEnumElement elements = (element as IGroupElement).Elements;
                    elements.Reset();
                    for (IElement i = elements.Next(); i != null; i = elements.Next())
                    {
                        graphicsContainer.DeleteElement(i);
                    }
                    graphicsContainer.AddElement(element, -1);
                    graphicsContainerSelect.SelectElement(element);
                }
                element = this.ienumElement_0.Next();
            }
        }
예제 #16
0
        /// <summary>
        /// 删除所有与此相关的元素
        /// </summary>
        public void DeleteAllElements(IHookHelper hookHelper)
        {
            //m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            IGraphicsContainer g = hookHelper.ActiveView.GraphicsContainer;

            //RemoveElementFromGroupElement(m_Elements);
            try
            {
                //g.DeleteElement(m_Elements as IElement);
                g.DeleteAllElements();
            }
            catch
            { }
            finally
            {
                m_TraceElement  = null;
                m_LabelElement  = null;
                m_VertexElement = null;
                m_Elements      = null;
                //最后再刷新一次
                hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                hookHelper.ActiveView.Refresh();
            }
        }
예제 #17
0
파일: ElementCustom.cs 프로젝트: YB9527/CG
        public ElementCustom(IGraphicsContainer graphicsContainer, IList <IElement> Elements)
        {
            string name;

            this.GraphicsContainer = graphicsContainer;
            this.Elements          = Elements;
            IList <IElement> list;

            ElementNameDic = new Dictionary <string, IList <IElement> >();
            foreach (IElement element in Elements)
            {
                IElementProperties pElmentProperties = element as IElementProperties;
                if (pElmentProperties != null)
                {
                    name = pElmentProperties.Name;
                    if (!Utils.IsStrNull(name))
                    {
                        if (name.Equals("图层"))
                        {
                            TCElement = element;
                            continue;
                        }
                        if (ElementNameDic.TryGetValue(name, out list))
                        {
                            list.Add(element);
                        }
                        else
                        {
                            list = new List <IElement>();
                            list.Add(element);
                            ElementNameDic.Add(name, list);
                        }
                    }
                }
            }
        }
예제 #18
0
        /// <summary>
        /// 设置IGeometry的ISymbol
        /// </summary>
        /// <param name="pGeo"></param>
        /// 函数需要改进
        public static void SetGeoColor(IGeometry pGeo, IGraphicsContainer pGraphContainer, string strRasterName, ref Hashtable hashElementList)
        {
            IElement ipElement = GetElement(pGeo, strRasterName);

                ((IElementProperties)ipElement).Name = strRasterName;

                pGraphContainer.AddElement(ipElement, 0);

                if (!hashElementList.Contains(strRasterName))
                {
                    hashElementList.Add(strRasterName, ipElement);
                }
        }
예제 #19
0
파일: CreateArea.cs 프로젝트: ESOmenium/AIS
        private void ClearGraphicsFromMap(IMap pMap)
        {
            IGraphicsContainer graphicsContainer = (IGraphicsContainer)pMap; // Explicit Cast

            graphicsContainer.DeleteAllElements();
        }
		private void UnWireGraphicsEvents()
		{
			try
			{
				if (m_naWindowEventSource == null)
					return;

				if (m_graphicsEventSource == null)
					return;

				((ESRI.ArcGIS.Carto.IGraphicsContainerEvents_Event)(m_graphicsEventSource)).AllElementsDeleted -= m_AllGraphicsDeleted;
				((ESRI.ArcGIS.Carto.IGraphicsContainerEvents_Event)(m_graphicsEventSource)).ElementAdded -= m_GraphicAdded;
				((ESRI.ArcGIS.Carto.IGraphicsContainerEvents_Event)(m_graphicsEventSource)).ElementDeleted -= m_GraphicDeleted;
				((ESRI.ArcGIS.Carto.IGraphicsContainerEvents_Event)(m_graphicsEventSource)).ElementsAdded -= m_GraphicsAdded;
				((ESRI.ArcGIS.Carto.IGraphicsContainerEvents_Event)(m_graphicsEventSource)).ElementUpdated -= m_GraphicUpdated;

				m_graphicsEventSource = null;

				SubsetHelperUI.ClearEIDArrayParameterValues(m_nax, SubsetHelperUI.GraphicsEIDArrayBaseName);
			}
			catch (Exception ex)
			{
				string msg = SubsetHelperUI.GetFullExceptionMessage(ex);
				MessageBox.Show(msg, "UnWire Graphics Events");
			}
		}
예제 #21
0
        public override void OnClick()
        {
            SysCommon.Error.frmInformation eerorFrm = new SysCommon.Error.frmInformation("是", "否", "删除数据将无法恢复,确定吗?");
            eerorFrm.Owner = (m_Hook as Plugin.Application.IAppFormRef).MainForm;
            if (eerorFrm.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }
            //执行成果数据删除操作(在列表中选中要删除的数据项,进行删除)

            Exception ex = null;

            #region 获取连接信息
            DevComponents.AdvTree.Node mDBNode     = m_Hook.ProjectTree.SelectedNode;
            DevComponents.AdvTree.Node Deltreenode = null;
            string ipStr    = "";
            string ip       = "";
            string id       = "";
            string password = "";
            string ConnStr  = "";
            int    datatype = -1;
            SysCommon.DataBase.SysTable pSysDB = new SysCommon.DataBase.SysTable();    //属性库连接类

            while (mDBNode.Parent != null)
            {
                mDBNode = mDBNode.Parent;
            }
            if (mDBNode.Name == "文件连接")
            {
                Deltreenode = mDBNode;
                System.Xml.XmlElement dbElem = mDBNode.Tag as System.Xml.XmlElement;
                if (dbElem == null)
                {
                    return;
                }
                ipStr    = dbElem.GetAttribute("MetaDBConn");
                ip       = dbElem.GetAttribute("服务器");
                id       = dbElem.GetAttribute("用户");
                password = dbElem.GetAttribute("密码");
                //ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ipStr + ";Persist Security Info=True";//元数据连接字符串
                ConnStr = ipStr;
                pSysDB.SetDbConnection(ConnStr, SysCommon.enumDBConType.ORACLE, SysCommon.enumDBType.ORACLE, out ex);
            }
            else
            {
                return;
            }
            #endregion
            if (EnumTreeNodeType.DATAITEM.ToString() == m_Hook.ProjectTree.SelectedNode.DataKey.ToString())
            {
                #region 在树节点上选择要删除的数据
                if (m_Hook.ProjectTree.SelectedNode.Tag == null)
                {
                    return;
                }
                if (m_Hook.ProjectTree.SelectedNode.Tag.ToString() == "")
                {
                    return;
                }
                long   dataID   = int.Parse(m_Hook.ProjectTree.SelectedNode.Tag.ToString());//数据
                string DataType = m_Hook.ProjectTree.SelectedNode.Parent.Tag.ToString();;
                try
                {
                    datatype = Convert.ToInt32(DataType);
                }
                catch
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("错误提示!", "获取数据类型失败!");
                    return;
                }
                if (2 != datatype)////数据类型不为控制点控制点数据

                {
                    string FilePath = m_Hook.ProjectTree.SelectedNode.Name;
                    string FileName = m_Hook.ProjectTree.SelectedNode.Text.Trim();
                    bool   Delstate = ModDBOperator.DelDataItem(FilePath, FileName, ip, id, password, out ex);
                    if (!Delstate)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("错误", "文件库中删除文件:" + FilePath + "/" + FileName + "失败!" + "\n请确认文件是否存在或是否为占用状态!");
                        return;
                    }
                    m_Hook.ProjectTree.SelectedNode.Remove();
                    ModDBOperator.DelDataItem(dataID, datatype, pSysDB, out ex);
                    if (null != ex)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("错误", "元信息数据库中删除数据文件记录失败!");
                        return;
                    }
                }
                else/////数据类型为控制点数据

                {
                    ModDBOperator.DelDataItem(dataID, datatype, pSysDB, out ex);
                    if (null != ex)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("错误", "元信息数据库中删除数据文件记录失败!");
                        return;
                    }
                    m_Hook.ProjectTree.SelectedNode.Remove();
                }
                #endregion
            }
            else if (m_Hook.DataInfoGrid.Rows.Count > 0)
            {
                #region 其他所有节点
                DevComponents.AdvTree.Node Selnode = m_Hook.ProjectTree.SelectedNode;
                if (null == Selnode.DataKey)
                {
                    return;
                }
                string ID       = "";
                long   lid      = -1;
                string FileName = "";
                string FilePath = "";
                string type     = "";

                FrmProcessBar frmbar = new FrmProcessBar();
                frmbar.SetFrmProcessBarText("删除操作:");
                frmbar.Show();
                List <int> delrowlist = new List <int>();
                if (EnumTreeNodeType.PRODUCTPYPE.ToString() == Selnode.DataKey.ToString())
                {
                    #region  中的是产品类型节点(标准、非标准、控制点数据)
                    type = Selnode.Text;
                    switch (type)
                    {
                    case "标准图幅":
                        datatype = 0;
                        break;

                    case "非标准图幅":
                        datatype = 1;
                        break;

                    case "控制点数据":
                        datatype = 2;
                        break;

                    default:
                        datatype = -1;
                        break;
                    }
                    if (datatype == -1)
                    {
                        return;
                    }
                    frmbar.SetFrmProcessBarMax((long)m_Hook.DataInfoGrid.Rows.Count);
                    for (int i = 0; i < m_Hook.DataInfoGrid.Rows.Count; i++)
                    {
                        frmbar.SetFrmProcessBarValue((long)i);
                        Application.DoEvents();
                        if (false == m_Hook.DataInfoGrid.Rows[i].Selected)
                        {
                            continue;
                        }
                        try
                        {
                            ID = m_Hook.DataInfoGrid.Rows[i].Cells["ID"].FormattedValue.ToString().Trim();
                            if (string.IsNullOrEmpty(ID))
                            {
                                continue;
                            }
                            lid      = Convert.ToInt64(ID);
                            FileName = m_Hook.DataInfoGrid.Rows[i].Cells["数据文件名"].FormattedValue.ToString().Trim();
                            FilePath = m_Hook.DataInfoGrid.Rows[i].Cells["存储位置"].FormattedValue.ToString().Trim();
                        }
                        catch
                        {
                            eerorFrm       = new SysCommon.Error.frmInformation("是", "否", "数据文件:" + FileName + "删除失败,是否继续删除?");
                            eerorFrm.Owner = (m_Hook as Plugin.Application.IAppFormRef).MainForm;
                            if (eerorFrm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                continue;
                            }
                            else
                            {
                                frmbar.Close();
                                return;
                            }
                        }

                        #region 在文件库中删除数据文件

                        //////////////////在文件库中删除数据文件////////////////////////////////
                        frmbar.SetFrmProcessBarText("正在删除文件:" + FileName);
                        Application.DoEvents();
                        if (2 != datatype)////数据类型为控制点控制点数据不执行文件的删除操作

                        {
                            bool Delstate = ModDBOperator.DelDataItem(FilePath, FileName, ip, id, password, out ex);
                            if (!Delstate)
                            {
                                eerorFrm       = new SysCommon.Error.frmInformation("是", "否", "数据文件\n'" + FilePath + "/" + FileName + "'\n删除失败。\n" + "请确认文件是否存在或是否为占用状态" + "!\n是否继续删除?");
                                eerorFrm.Owner = (m_Hook as Plugin.Application.IAppFormRef).MainForm;
                                if (eerorFrm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                {
                                    continue;
                                }
                                else
                                {
                                    frmbar.Close();
                                    return;
                                }
                            }
                        }
                        #endregion
                        #region 在元数据表中删除成果信息
                        ///////////////////在元数据表中删除成果信息/////////////////////////
                        ModDBOperator.DelDataItem(lid, datatype, pSysDB, out ex);
                        if (null != ex)
                        {
                            eerorFrm       = new SysCommon.Error.frmInformation("是", "否", "数据文件\n'" + FileName + "'\n元信息删除失败。\n" + "请确认元信息库的连接信息。" + "!\n是否继续删除?");
                            eerorFrm.Owner = (m_Hook as Plugin.Application.IAppFormRef).MainForm;
                            if (eerorFrm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                continue;
                            }
                            else
                            {
                                frmbar.Close();
                                return;
                            }
                        }
                        // m_Hook.DataInfoGrid.Rows.Remove(m_Hook.DataInfoGrid.Rows[i]);
                        // i = i - 1;
                        delrowlist.Add(i);
                        #endregion
                        #region 在树节点中删除文件节点

                        /////////////////////在树节点中删除文件节点///////////////////////////
                        ModDBOperator.DelNodeByNameAndText(Deltreenode, FilePath, FileName, out ex);
                        if (null != ex)
                        {
                            eerorFrm       = new SysCommon.Error.frmInformation("是", "否", "树节点删除失败。原因为:\n" + ex.Message + "!\n是否继续删除?");
                            eerorFrm.Owner = (m_Hook as Plugin.Application.IAppFormRef).MainForm;
                            if (eerorFrm.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                            {
                                frmbar.Close();
                                return;
                            }
                            //else
                            //    return;
                        }
                        #endregion
                    }
                    #endregion
                }
                else  //除产品类型节点以外的所有节点
                {
                    frmbar.SetFrmProcessBarMax((long)m_Hook.DataInfoGrid.Rows.Count);
                    for (int i = 0; i < m_Hook.DataInfoGrid.Rows.Count; i++)
                    {
                        #region 获取必要信息
                        if (false == m_Hook.DataInfoGrid.Rows[i].Selected)
                        {
                            continue;
                        }
                        frmbar.SetFrmProcessBarValue((long)i);
                        int DataType = -1;//产品的类型(标准,非标准,属性)
                        try
                        {
                            ID = m_Hook.DataInfoGrid.Rows[i].Cells["ID"].FormattedValue.ToString().Trim();
                            if (string.IsNullOrEmpty(ID))
                            {
                                continue;
                            }
                            lid      = Convert.ToInt64(ID);
                            FileName = m_Hook.DataInfoGrid.Rows[i].Cells["数据文件名"].FormattedValue.ToString().Trim();
                            FilePath = m_Hook.DataInfoGrid.Rows[i].Cells["存储位置"].FormattedValue.ToString().Trim();
                            type     = m_Hook.DataInfoGrid.Rows[i].Cells["数据类型"].FormattedValue.ToString().Trim();
                            if ("标准图幅数据" == type)
                            {
                                datatype = EnumDataType.标准图幅.GetHashCode();
                            }
                            else if ("非标准图幅数据" == type)
                            {
                                datatype = EnumDataType.非标准图幅.GetHashCode();
                            }
                            else if ("控制点数据" == type)
                            {
                                datatype = EnumDataType.控制点数据.GetHashCode();
                            }
                        }
                        catch
                        {
                            eerorFrm       = new SysCommon.Error.frmInformation("是", "否", "数据文件:" + FileName + "删除失败。原因为:数据文件的ID获取失败\n" + "是否继续删除?");
                            eerorFrm.Owner = (m_Hook as Plugin.Application.IAppFormRef).MainForm;
                            if (eerorFrm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                continue;
                            }
                            else
                            {
                                frmbar.Close();
                                return;
                            }
                        }
                        #endregion
                        #region 在元信息表中删除
                        frmbar.SetFrmProcessBarText("正在删除文件:" + FileName);
                        if (ex != null)
                        {
                            ex = new Exception("连接元数据库失败!连接地址为:" + ConnStr);
                            pSysDB.CloseDbConnection();
                            return;
                        }
                        if (lid != -1 && datatype != -1)
                        {
                            ModDBOperator.DelDataItem(lid, datatype, pSysDB, out ex);
                            if (null != ex)
                            {
                                eerorFrm       = new SysCommon.Error.frmInformation("是", "否", "数据文件元信息删除失败。\n" + "请检查元信息库连接信息" + "!\n是否继续删除?");
                                eerorFrm.Owner = (m_Hook as Plugin.Application.IAppFormRef).MainForm;
                                if (eerorFrm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                {
                                    continue;
                                }
                                else
                                {
                                    frmbar.Close();
                                    return;
                                }
                            }
                        }

                        #endregion
                        #region 在文件库中删除

                        if (2 != datatype)////数据类型为控制点控制点数据则不进行文件的删除操作
                        {
                            bool Delstate = ModDBOperator.DelDataItem(FilePath, FileName, ip, id, password, out ex);
                            if (!Delstate)
                            {
                                eerorFrm       = new SysCommon.Error.frmInformation("是", "否", "数据文件\n'" + FilePath + "/" + FileName + "'\n删除失败。\n" + " 请确认文件是否存在或是否为占用状态。" + "\n是否继续删除?");
                                eerorFrm.Owner = (m_Hook as Plugin.Application.IAppFormRef).MainForm;
                                if (eerorFrm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                {
                                    continue;
                                }
                                else
                                {
                                    frmbar.Close();
                                    return;
                                }
                            }
                        }
                        #endregion
                        #region 记录DataGrid中要删除的行
                        delrowlist.Add(i);
                        #endregion
                        #region 在树节点中删除文件节点

                        ModDBOperator.DelNodeByNameAndText(Deltreenode, FilePath, FileName, out ex);
                        if (null != ex)
                        {
                            eerorFrm       = new SysCommon.Error.frmInformation("是", "否", "树节点删除失败。原因为:\n" + ex.Message + "!\n是否继续删除?");
                            eerorFrm.Owner = (m_Hook as Plugin.Application.IAppFormRef).MainForm;
                            if (eerorFrm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                continue;
                            }
                            else
                            {
                                frmbar.Close();
                                return;
                            }
                        }
                        #endregion
                    }
                }
                /////数据列表中移除相应的行
                if (null != delrowlist)
                {
                    for (int j = 0; j < delrowlist.Count; j++)
                    {
                        m_Hook.DataInfoGrid.Rows.Remove(m_Hook.DataInfoGrid.Rows[delrowlist[j] - j]);
                    }
                }
                frmbar.Close();
                #endregion
            }
            #region 图层处理
            if (ModData.v_AppFileDB.MapControl.LayerCount > 0 && datatype != 2)
            {
                IGroupLayer Glayer = null;
                for (int i = 0; i < ModData.v_AppFileDB.MapControl.LayerCount; i++)
                {
                    ILayer getlayer = ModData.v_AppFileDB.MapControl.get_Layer(i);
                    if (getlayer.Name == "项目范围图")
                    {
                        Glayer = getlayer as IGroupLayer;
                    }
                }
                if (null != Glayer)
                {
                    ICompositeLayer comlayer  = Glayer as ICompositeLayer;
                    string          layername = null;
                    switch (datatype)
                    {
                    case 0:
                        layername = "MapFrame_";
                        break;

                    case 1:
                        layername = "Range_";
                        break;

                    default:
                        layername = "_";
                        break;
                    }
                    if (comlayer != null)
                    {
                        for (int i = 0; i < comlayer.Count; i++)
                        {
                            ILayer orglayer = comlayer.get_Layer(i);
                            string lname    = orglayer.Name;
                            if (lname.Contains(layername))
                            {
                                Glayer.Delete(orglayer);
                                ModData.v_AppFileDB.TOCControl.Update();
                                ModData.v_AppFileDB.MapControl.ActiveView.Refresh();
                            }
                        }
                    }
                }
            }
            if (datatype == EnumDataType.控制点数据.GetHashCode())
            {
                IGraphicsContainer pGra = ModData.v_AppFileDB.MapControl.Map as IGraphicsContainer;
                pGra.DeleteAllElements();
                ModData.v_AppFileDB.MapControl.ActiveView.Refresh();
            }
            #endregion


            //刷新时间列表框

            ModDBOperator.LoadComboxTime(ConnStr, out ex);
            if (ex != null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("错误", "加载时间列表框失败," + ex.Message);
                return;
            }
        }
예제 #22
0
        //创建选择要素的轮廓线
        private void CreateSelectElementFrame()
        {
            IGraphicsContainer       pGraphicsContainer       = m_hookHelper.ActiveView.GraphicsContainer;
            IGraphicsContainerSelect pGraphicsContainerSelect = pGraphicsContainer as IGraphicsContainerSelect;
            int          SelectElementCount = pGraphicsContainerSelect.ElementSelectionCount;
            IEnumElement pEnumElement       = pGraphicsContainerSelect.SelectedElements;

            pEnumElement.Reset();
            IElement pElement = pEnumElement.Next();

            for (int i = 0; i < SelectElementCount; i++)
            {
                IElementProperties pElementProperties = pElement as IElementProperties;
                IFrameElement      pFrameElement      = pElement as IFrameElement;
                IFrameProperties   pFrameProperties   = pFrameElement as IFrameProperties;
                //边框的间距和圆角
                if (SymbolBorder != null)
                {
                    if (this.txtBorderGap.Text != null)
                    {
                        SymbolBorder.Gap = double.Parse(this.txtBorderGap.Text);
                    }
                    if (this.txtBorderAngle.Text != null)
                    {
                        SymbolBorder.CornerRounding = short.Parse(this.txtBorderAngle.Text);
                    }
                }
                if (SymbolBackground != null)
                {
                    if (txtBackgroundGap.Text != null)
                    {
                        SymbolBackground.Gap = double.Parse(this.txtBackgroundGap.Text);
                    }
                    if (txtBackgroundAngle.Text != null)
                    {
                        SymbolBackground.CornerRounding = short.Parse(this.txtBackgroundAngle.Text);
                    }
                }
                if (SymbolShadow != null)
                {
                    if (txtShadowX.Text != null)
                    {
                        SymbolShadow.HorizontalSpacing = double.Parse(this.txtShadowX.Text);
                    }
                    if (txtShadowY.Text != null)
                    {
                        SymbolShadow.VerticalSpacing = double.Parse(this.txtShadowY.Text);
                    }
                    if (txtShadowAngle.Text != null)
                    {
                        SymbolShadow.CornerRounding = short.Parse(this.txtShadowAngle.Text);
                    }
                }
                //边框
                pFrameProperties.Border = SymbolBorder;
                //背景
                pFrameProperties.Background = SymbolBackground;
                //阴影
                pFrameProperties.Shadow = SymbolShadow;

                pElement = pEnumElement.Next();
            }
        }
예제 #23
0
        public IElement addTitleToLayout(IMxDocument pMxDoc,double S, double x, double y,  IGraphicsContainer pGc, bool b, string texto)
        {
            ITextElement pTxtElem;
            ITextSymbol pTxtSym = default(ITextSymbol);
            IRgbColor myColor = default(IRgbColor);
            stdole.IFontDisp myFont;
            IElement pElem;
            IEnvelope pEnv;
            IPoint pPoint = default(IPoint);
            try{
                // pGc.Reset()
                //Set the font and color properties
                //for the title
                myFont = (stdole.IFontDisp)new stdole.StdFont();
                myFont.Name = "Times New Roman";
                myFont.Bold = b;
               // myFont.Size = S;
                myColor = new RgbColor();
                myColor.Red = 0;
                myColor.Green = 0;
                myColor.Blue = 0;
                ///''''''''''''''''''''''''''''''
                //Create a text element
                pTxtElem = (ITextElement)new TextElement();

                //Create a text symbol
                pTxtSym = new TextSymbol();
                pTxtSym.Color = myColor;
                pTxtSym.Font = myFont;
                pTxtSym.Size = S;
                //Set symbol property
                pTxtElem.Symbol = pTxtSym;

                //set the text property to be the layer's name (Uppercase)
                pTxtElem.Text = texto;

                //Create an envelope for the TextElements Geometry
                pEnv = (IEnvelope)new Envelope();
                pPoint = new ESRI.ArcGIS.Geometry.Point();

                pPoint.X = x;
                pPoint.Y = y;
                pEnv.LowerLeft = pPoint;
                pPoint.X = 1;
                pPoint.Y = 1;
                pEnv.UpperRight = pPoint;
                //set the text elements geomtery
                pElem = (IElement)pTxtElem;
                pElem.Geometry = pEnv;

                //Add the element to the graphics container
                pGc.AddElement(pElem, 1);
                pMxDoc.ActiveView.Refresh();
                return (pElem);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "clsMapTools.addTitleToLayout");
                MessageBox.Show("Error: " + ex.StackTrace);
                return null ;
            }
        }
예제 #24
0
파일: Form1.cs 프로젝트: dalinhuang/CUIT3D
        private void Form1_Load(object sender, EventArgs e)
        {
            j = 3;
            comboBox1.Items.Clear();

            string filePath = Application.StartupPath + "\\..\\..\\..\\..\\最新arcsense\\无标题11.sxd";
            if (axSceneControl1.CheckSxFile(filePath))
            {
                axSceneControl1.LoadSxFile(filePath);
                axTOCControl1.SetBuddyControl(axSceneControl1);
            }
            lyrCount = axSceneControl1.Scene.LayerCount;
            //MessageBox.Show(axSceneControl1.Scene.LayerCount.ToString());
            for (i = 0; i <= lyrCount - 1; i++)
            {
              //  MessageBox.Show(axSceneControl1.Scene.get_Layer(i).Name);
                comboBox1.Items.Add(axSceneControl1.Scene.get_Layer(i).Name);
            }
            String sFilename;
            sFilename = @"C:\Users\dull\Desktop\新文件\校园代码\最新底图制作\无标题.mxd";
            if (axMapControl1.CheckMxFile(sFilename))
            {
                axMapControl1.LoadMxFile(sFilename);
             //       axTOCControl1.SetBuddyControl(axMapControl1);
             }

            string path = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
            int t;
            for (t = 0; t < path.Length; t++)
            {
                if (path.Substring(t, 24) == "WindowsFormsApplication1")
                {
                    break;
                }
            }
            string name = path.Substring(0, t - 1) + "\\WindowsFormsApplication1\\road.gdb";
            pFeatureWorkspace = OpenWorkspace(name) as IFeatureWorkspace;
            pNetworkDataset = OpenNetworkDataset_Other(pFeatureWorkspace as IWorkspace, "zhz_ND", "zhz");

            pNAContext = CreateNAContext(pNetworkDataset);
            pInputFC = pFeatureWorkspace.OpenFeatureClass("zhz_ND_Junctions");
            //pInputFC = pFeatureWorkspace.OpenFeatureClass("woqu");
            pVertexFC = pFeatureWorkspace.OpenFeatureClass("zhz_ND_Junctions");

            IFeatureLayer pVertexFL = new FeatureLayerClass();
            pVertexFL.FeatureClass = pFeatureWorkspace.OpenFeatureClass("zhz_ND_Junctions");
            pVertexFL.Name = pVertexFL.FeatureClass.AliasName;
            axMapControl2.AddLayer(pVertexFL, 0);

            IFeatureLayer pRoadFL = new FeatureLayerClass();
            pRoadFL.FeatureClass = pFeatureWorkspace.OpenFeatureClass("road1");
            pRoadFL.Name = pRoadFL.FeatureClass.AliasName;
            axMapControl2.AddLayer(pRoadFL, 0);

            ILayer pLayer;
            INetworkLayer pNetworkLayer = new NetworkLayerClass();
            pNetworkLayer.NetworkDataset = pNetworkDataset;
            pLayer = pNetworkLayer as ILayer;
            pLayer.Name = "Network Dataset";
            axMapControl2.AddLayer(pLayer, 0);

            //Create a Network Analysis Layer and add to ArcMap
            INALayer naLayer = pNAContext.Solver.CreateLayer(pNAContext);
            pLayer = naLayer as ILayer;
            pLayer.Name = pNAContext.Solver.DisplayName;
            axMapControl2.AddLayer(pLayer, 0);

            pActiveView = axMapControl2.ActiveView;
            pMap = pActiveView.FocusMap;
            pGraphicsContainer = pMap as IGraphicsContainer;

              //  string CurrentPath = Directory.GetCurrentDirectory();
             //   Directory.SetCurrentDirectory(CurrentPath + "\\..\\..\\..\\..\\最新底图制作");
             //   string FilePath = Directory.GetCurrentDirectory();
             //   axMapControl1.AddShapeFile(FilePath, "教学区.shp");
             //   axMapControl1.AddShapeFile(FilePath, "活动区.shp");
              //  axMapControl1.AddShapeFile(FilePath, "宿舍.shp");
              //  axMapControl1.AddShapeFile(FilePath, "场馆区.shp");
            //    axMapControl1.AddShapeFile(FilePath, "办公区.shp");
            //    axMapControl1.AddShapeFile(FilePath, "其他.shp");
             //   axMapControl1.AddShapeFile(FilePath, "底图.shp");
             //   axMapControl1.AddShapeFile(FilePath, "无标题.mxd");
        }
예제 #25
0
        private void AddPointElement(IGeometry pGeom, IGraphicsContainer pGraphicsContainer)
        {
            ISimpleMarkerSymbol pSimpleSym = new SimpleMarkerSymbolClass();
            pSimpleSym.Style = esriSimpleMarkerStyle.esriSMSCross;
            pSimpleSym.Size = 10;
            pSimpleSym.Color = getRGB(255, 0, 0); ;

            IMarkerElement pMarkerElem = null;
            IElement pElem;
            pElem = new MarkerElementClass();
            pElem.Geometry = pGeom as IPoint;
            pMarkerElem = pElem as IMarkerElement;
            pMarkerElem.Symbol = pSimpleSym;
            pGraphicsContainer.AddElement(pElem, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
예제 #26
0
 private void AddLineElement(IGeometry pGeom, IGraphicsContainer pGraphicsContainer)
 {
     ISimpleLineSymbol pLineSym;
     pLineSym = new SimpleLineSymbolClass();
     pLineSym.Color = getRGB(255, 0, 0);
     pLineSym.Width = 1;
     pLineSym.Style = esriSimpleLineStyle.esriSLSSolid;
     ILineElement plineEle;
     plineEle = new LineElementClass();
     plineEle.Symbol = pLineSym;
     IElement pEles;
     pEles = plineEle as IElement;
     pEles.Geometry = pGeom as IPolyline;
     pGraphicsContainer.AddElement(pEles, 0);
     pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
 }
예제 #27
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add SelectPoint.OnMouseDown implementation

            pActiveView = m_hookHelper.ActiveView;
            pMap = m_hookHelper.FocusMap;
            pGraphicsContainer = pMap as IGraphicsContainer;
            IPoint pPt = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X,
            Y);

            if (newItem==null)
            {
                newItem = new ListViewItem(pointCount.ToString());
                newItem.SubItems.Add(pPt.X.ToString("f3"));
                newItem.SubItems.Add(pPt.Y.ToString("f3"));
                frmAdjPoint.FromPoint.AddPoint(pPt, ref obj, ref obj);
            }

            /*if (clickCount == 2&&newItem.SubItems.Count<=4)
            {
                newItem.SubItems.Add(pPt.X.ToString("f3"));
                newItem.SubItems.Add(pPt.Y.ToString("f3"));
                frmAdjPoint.ToPoint.AddPoint(pPt, ref obj, ref obj);
                clickCount++;
            }*/

            AddPointElement((IGeometry)pPt, pGraphicsContainer);

            if (pLineFeedback == null)
            {
                pLineFeedback = new NewLineFeedbackClass();
                pLineFeedback.Display = pActiveView.ScreenDisplay;
                pLineFeedback.Start(pPt);
            }
            else
            {
                pLineFeedback.AddPoint(pPt);
            }
        }
        /// <summary>
        /// Method used to remove graphics from the graphics container
        /// Elements are tagged with a GUID on the IElementProperties.Name property
        /// </summary>
        /// <param name="gc">map graphics container</param>
        /// <param name="list">list of GUIDs to remove</param>
        internal void RemoveGraphics(IGraphicsContainer gc, List<string> list)
        {
            if (gc == null || !list.Any())
                return;

            var elementList = new List<IElement>();
            gc.Reset();
            var element = gc.Next();
            while (element != null)
            {
                var eleProps = element as IElementProperties;
                if (list.Contains(eleProps.Name))
                {
                    elementList.Add(element);
                }
                element = gc.Next();
            }

            foreach (var ele in elementList)
            {
                gc.DeleteElement(ele);
            }

            list.Clear();
            elementList.Clear();

            RaisePropertyChanged(() => HasMapGraphics);
        }
예제 #29
0
 public static void load(string path)
 {
     g_pMyMapCtrl = (IMapControl3)g_pAxMapControl.Object;
     g_pMap = g_pAxMapControl.Map;
     g_pGraph = (IGraphicsContainer)g_pMap;
     IWorkspace workspace = SDEOperation.connectSde(path);//dfjia
     g_pCurrentWorkSpace = workspace;
     g_CurWorkspaceEdit = (IWorkspaceEdit)workspace;
     contextMenu.SetHook(g_pAxMapControl.Object);
     //g_pAxMapControl.ActiveView.Refresh();
 }
		public static IGeometry GetSearchGeometryFromGraphics(IGraphicsContainer graphics)
		{
			IGeometryCollection geometryBag = new GeometryBagClass();
			IElement element;
			IGeometry geometry;

			graphics.Reset();
			element = graphics.Next();

			object before = Type.Missing;
			object after = Type.Missing;

			while (element != null)
			{
				geometry = element.Geometry;
				if (geometry is IPolygon)
					geometryBag.AddGeometry(geometry, ref before, ref after);

				element = graphics.Next();
			}

			IGeometry searchGeometry = geometryBag as IGeometry;

			return searchGeometry;
		}
		private void Form1_Load(object sender, System.EventArgs e)
		{
			m_MapControl = (IMapControl2) axMapControl1.GetOcx();

			//Find sample data
			string sFilePath = @"..\..\..\Data\World";

			//Add sample shapefile data
			m_MapControl.AddShapeFile(sFilePath, "world30");
			m_MapControl.AddLayerFromFile(sFilePath + @"\continents.lyr",0);

			//Symbolize the data
			SymbolizeData(m_MapControl.get_Layer(0), 0.1, GetRGBColor(0, 0, 0), GetRGBColor(0, 128, 0));
			SymbolizeData(m_MapControl.get_Layer(1), 0.1, GetRGBColor(0, 0, 0), GetRGBColor(140, 196, 254));
			//Set up a global Geographic Coordinate System
			MakeCoordinateSystems();

			//Get the MapControl's graphics container and get the IGraphicsContainer interface
			m_GraphicsContainer = m_MapControl.ActiveView.GraphicsContainer;

			//Populate an array with agent id's and locations
			LoadAgentArray();

			//Loop through the array and display each agent location
			for (int i = 0; i <= 19; i++)
			{
				DisplayAgentLocation(agentArray[i]);
			}

			timer1.Interval = 800;
		}
예제 #32
0
        /// <summary>
        /// 设置IGeometry的ISymbol
        /// </summary>
        /// <param name="pGeo"></param>
        /// 函数需要改进
        public static void SetGeoColor(IGeometry pGeo, IGraphicsContainer pGraphContainer, string strElementName)
        {
            IElement ipElement = null;

            if (pGeo.GeometryType == esriGeometryType.esriGeometryPolyline)
            {
                ILineElement ipLineElement = new LineElementClass();
                RgbColor ipColor = new RgbColor();
                ipElement = (IElement)ipLineElement;
                ipElement.Geometry = pGeo;
                ISimpleFillSymbol ipFillSymbol = new SimpleFillSymbolClass();
                ILineSymbol ipLineSymbol = ipFillSymbol.Outline;
                ipLineSymbol.Width = 2.0;
                ipColor.Red = 0;
                ipColor.Blue = 0;
                ipColor.Green = 255;
                ipLineSymbol.Color = (IColor)ipColor;
                ipLineElement.Symbol = ipLineSymbol;
                ((IElementProperties)ipElement).Name = strElementName;
                pGraphContainer.AddElement(ipElement, 0);
            }
            else if (pGeo.GeometryType == esriGeometryType.esriGeometryPolygon)
            {
                RgbColor ipColor = new RgbColor();
                IPolygonElement ipPolygonElement = new PolygonElementClass();
                ipElement = (IElement)ipPolygonElement;
                ipElement.Geometry = pGeo;
                ISimpleFillSymbol ipFillSymbol = new SimpleFillSymbolClass();
                ILineSymbol ipLineSymbol = ipFillSymbol.Outline;
                ipLineSymbol.Width = 2.0;
                ipColor.Red = 0;
                ipColor.Blue = 0;
                ipColor.Green = 255;
                ipLineSymbol.Color = (IColor)ipColor;
                ipFillSymbol.Outline = ipLineSymbol;
                IFillShapeElement pFillElement = (IFillShapeElement)ipPolygonElement;
                ipFillSymbol.Style = esriSimpleFillStyle.esriSFSHollow;
                pFillElement.Symbol = ipFillSymbol;
                ((IElementProperties)ipElement).Name = strElementName;
                pGraphContainer.AddElement(ipElement, 0);
            }
        }
 public Size GetDesiredSize(IGraphicsContainer gc, Size limit)
 {
   return Size.Constrain(limit);
 }
예제 #34
0
        private void ClearGra_Click(object obj, EventArgs eventArgs)
        {
            IGraphicsContainer graphicsContainer = (IGraphicsContainer)m_iApp.ActiveView;

            graphicsContainer.DeleteAllElements();
        }
        /// <summary>
        /// Method used to remove graphics from the graphics container
        /// Elements are tagged with a GUID on the IElementProperties.Name property
        /// Removes graphics from all tabs, not just the tab that is currently active
        /// </summary>
        private void RemoveGraphics(IGraphicsContainer gc, bool removeOnlyTemporary)
        {
            if (gc == null || !GraphicsList.Any())
                return;

            // keep track of the graphics that we need to remove from the GraphicsList
            List<Graphic> removedGraphics = new List<Graphic>();

            var elementList = new List<IElement>();
            gc.Reset();
            var element = gc.Next();
            while (element != null)
            {
                var eleProps = element as IElementProperties;
                foreach (Graphic graphic in GraphicsList)
                {
                    if (graphic.UniqueId.Equals(eleProps.Name))
                    {
                        if (graphic.IsTemp == removeOnlyTemporary)
                        {
                            elementList.Add(element);
                            removedGraphics.Add(graphic);
                        }     
                            
                        break;
                    }
                }

                element = gc.Next();
            }

            foreach (var ele in elementList)
            {
                gc.DeleteElement(ele);
            }

            // clean up the GraphicsList and remove the necessary graphics from it
            foreach (Graphic graphic in removedGraphics)
            {
                GraphicsList.Remove(graphic);
            }

            elementList.Clear();
            RaisePropertyChanged(() => HasMapGraphics);
        }
예제 #36
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            if (!ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.ArcReader))
            {
                if (!ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop))
                {
                    MessageBox.Show("Unable to bind to ArcGIS runtime. Application will be shut down.");
                    return;
                }
            }
            //get the MapControl
            m_mapControl = (IMapControl3)axMapControl1.Object;

            //disable the Save menu (since there is no document yet)
            menuSaveDoc.Enabled = false;

            activeview = axMapControl1.Map as IActiveView;
            map = activeview.FocusMap;
            pScreenDisplay = activeview.ScreenDisplay;
            pGraphicsContainer = map as IGraphicsContainer;
            IGraphicsContainerSelect pGraphconSel = map as IGraphicsContainerSelect;
        }
예제 #37
0
 private void Form1_Load(object sender, EventArgs e)
 {
     this.pGraphicContainer = this.axMapControl1.ActiveView.FocusMap as IGraphicsContainer;
     this.pActiveView = this.axMapControl1.ActiveView;
     this.pScreenDisplay = this.axMapControl1.ActiveView.ScreenDisplay;
 }
		/// <summary>
		/// Occurs when this command is created
		/// </summary>
		/// <param name="hook">Instance of the application</param>
		public override void OnCreate(object hook)
		{
			if (hook == null)
				return;

			m_application = hook as IApplication;

			m_nax = null;
			m_naWindowEventSource = null;
			m_mapEventSource = null;
			m_graphicsEventSource = null;

			m_nax = SubsetHelperUI.GetNAXConfiguration(m_application) as INetworkAnalystExtension;
		}
예제 #39
0
        /// <summary>
        /// 显示并返回单个插值面状要素
        /// </summary>
        /// <param name="pDataRecords">数据记录</param>
        /// <param name="dblProp">差值参数</param>
        /// <returns>面状要素</returns>
        public CPolyline DisplayInterpolation(double dblProp, CPolyline lastcpl)
        {
            CPolyline cpl = GetTargetcpl(dblProp, lastcpl);

            //_DataRecords.ParameterInitialize.txtT.Text = "   t = " + dblProp.ToString();
            //_DataRecords.ParameterInitialize.txtVtPV.Text ="   VtPV = " + cpl.dblVtPV.ToString();

            //// 清除绘画痕迹
            //IMapControl4 m_mapControl = _DataRecords.ParameterInitialize.m_mapControl;
            //IGraphicsContainer pGra = m_mapControl.Map as IGraphicsContainer;
            //pGra.DeleteApLLElements();

            //if (dblProp == 0)
            //{
            //    int tt = 5;
            //}
            //else if (dblProp == 1)
            //{
            //    int ss = 5;
            //}


            ////对线段进行染色
            //for (int i = 0; i < cpl.SubCPlLt.Count; i++)
            //{
            //    double dblColor = 255;
            //    int intColor = Convert.ToInt32((Math.Abs(cpl.SubCPlLt[i].dblLengthV) - _dblMinLengthV) / _dblDiffLengthV * dblColor);
            //    intColor = Math.Abs(intColor);
            //    if (Math.Abs(cpl.SubCPlLt[i].dblLengthV) < _dblTX)
            //    {
            //        cpl.SubCPlLt[i].intGreen = 255;
            //    }

            //    else if (cpl.SubCPlLt[i].dblLengthV > 0)
            //    {
            //        if (intColor <= 255)
            //        {
            //            cpl.SubCPlLt[i].intRed = 255;
            //            cpl.SubCPlLt[i].intGreen = 255 - intColor;
            //            cpl.SubCPlLt[i].intBlue = 255 - intColor;
            //        }
            //        else
            //        {
            //            cpl.SubCPlLt[i].intRed = 255;
            //        }
            //    }
            //    else if (cpl.SubCPlLt[i].dblLengthV < 0)
            //    {
            //        if (intColor <= 255)
            //        {
            //            cpl.SubCPlLt[i].intRed = 255 - intColor;
            //            cpl.SubCPlLt[i].intGreen = 255 - intColor;
            //            cpl.SubCPlLt[i].intBlue = 255;
            //        }
            //        else
            //        {
            //            cpl.SubCPlLt[i].intBlue = 255;
            //        }
            //    }
            //}

            //for (int i = 0; i < cpl.SubCPlLt.Count; i++)
            //{
            //    CPolyline subcpl = cpl.SubCPlLt[i];
            //    CHelpFunc.ViewPolylineByRGB(m_mapControl, subcpl, subcpl.intRed, subcpl.intGreen, subcpl.intBlue);  //显示生成的线段
            //}

            ////对缓冲区进行染色
            //for (int i = 1; i < cpl.CptLt.Count -1; i++)
            //{
            //    double dblColor = 255;
            //    int intColor = Convert.ToInt32((Math.Abs(cpl.CptLt [i].dblAngleV ) - _dblMinAngleV) / _dblDiffAngleV * dblColor);
            //    intColor = Math.Abs(intColor);


            //    if (Math .Abs (cpl.CptLt[i].dblAngleV)<_dblTX)
            //    {
            //        cpl.CptLt[i].intGreen = 255;
            //    }
            //    else if (cpl.CptLt[i].dblAngleV > 0)
            //    {
            //        if (intColor <= 255)
            //        {
            //            cpl.CptLt[i].intRed = 255;
            //            cpl.CptLt[i].intGreen = 255 - intColor;
            //            cpl.CptLt[i].intBlue = 255 - intColor;
            //        }
            //        else
            //        {
            //            cpl.CptLt[i].intRed = 255;
            //        }
            //    }
            //    else if (cpl.CptLt[i].dblAngleV < 0)
            //    {
            //        if (intColor <= 255)
            //        {
            //            cpl.CptLt[i].intRed = 255 - intColor;
            //            cpl.CptLt[i].intGreen = 255 - intColor;
            //            cpl.CptLt[i].intBlue = 255;
            //        }
            //        else
            //        {
            //            cpl.CptLt[i].intBlue = 255;
            //        }
            //    }
            //}

            //for (int i = 1; i < cpl.CptLt.Count-1; i++)
            //{
            //    CPoint cpt=cpl.CptLt[i];
            //    CHelpFunc.ViewPolygonGeometryByRGB(m_mapControl, cpt.Buffer(5), cpt.intRed, cpt.intGreen, cpt.intBlue);  //显示缓冲区多边形
            //}

            ////显示线段
            //IActiveView pAv = pGra as IActiveView;
            //pAv.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);



            // 清除绘画痕迹
            IMapControl4       m_mapControl = _DataRecords.ParameterInitialize.m_mapControl;
            IGraphicsContainer pGra         = m_mapControl.Map as IGraphicsContainer;

            pGra.DeleteAllElements();
            CHelpFunc.ViewPolyline(m_mapControl, cpl);  //显示生成的线段


            return(cpl);
        }
예제 #40
0
        /// <summary>
        /// 模板替换
        /// </summary>
        /// <param name="_pageLayoutCtrl"></param>
        /// <param name="sTemplatePath"></param>
        /// <returns></returns>
        public static bool UseTemplateMxtToPageLayout(AxPageLayoutControl _pageLayoutCtrl, string sTemplatePath)
        {
            bool bSuccess = false;

            try
            {
                IMap        pMap           = null;
                IActiveView pActiveView    = null;
                IPageLayout pCurPageLayout = _pageLayoutCtrl.PageLayout;
                pActiveView = pCurPageLayout as IActiveView;
                pMap        = pActiveView.FocusMap;

                //读取模板
                IMapDocument pTempMapDocument = new MapDocumentClass();
                pTempMapDocument.Open(sTemplatePath, "");

                IPageLayout pTempPageLayout = pTempMapDocument.PageLayout;
                IPage       pTempPage       = pTempPageLayout.Page;
                IPage       pCurPage        = pCurPageLayout.Page;

                //替换单位及地图方向
                pCurPage.Orientation = pTempPage.Orientation;
                pCurPage.Units       = pTempPage.Units;

                //替换页面尺寸
                Double dWidth; Double dHeight;
                pTempPage.QuerySize(out dWidth, out dHeight);
                pCurPage.PutCustomSize(dWidth, dHeight);

                //删除当前layout中除了mapframe外的所有element
                IGraphicsContainer pGraph;
                pGraph = pCurPageLayout as IGraphicsContainer;
                pGraph.Reset();
                IElement  pElement  = pGraph.Next();
                IMapFrame pMapFrame = null;
                pMapFrame = pGraph.FindFrame(pMap) as IMapFrame;
                while (pElement != null)
                {
                    if (pElement is IMapFrame)
                    {
                        pMapFrame = pElement as IMapFrame;
                    }
                    else
                    {
                        pGraph.DeleteElement(pElement);
                        pGraph.Reset();
                    }
                    pElement = pGraph.Next();
                }

                //遍历模板中的PageLayout所有元素,替换当前PageLayout的所有元素
                IGraphicsContainer pTempGraph = pTempPageLayout as IGraphicsContainer;
                pTempGraph.Reset();
                pElement = pTempGraph.Next();
                IArray pArray = new ArrayClass();
                while (pElement != null)
                {
                    if (pElement is IMapFrame)
                    {
                        IElement pMapFrameElement = pMapFrame as IElement;
                        pMapFrameElement.Geometry = pElement.Geometry;
                    }
                    else
                    {
                        if (pElement is IMapSurroundFrame)
                        {
                            IMapSurroundFrame pTempMapSurroundFrame = pElement as IMapSurroundFrame;
                            pTempMapSurroundFrame.MapFrame = pMapFrame;
                            IMapSurround pTempMapSurround = pTempMapSurroundFrame.MapSurround;
                        }
                        pArray.Add(pElement);
                    }
                    pElement = pTempGraph.Next();
                }

                int pElementCount = pArray.Count;
                for (int i = 0; i < pArray.Count; i++)
                {
                    pGraph.AddElement(pArray.get_Element(pElementCount - 1 - i) as IElement, 0);
                }

                pActiveView.Refresh();
                bSuccess = true;
            }
            catch (Exception ex)
            {
            }
            return(bSuccess);
        }
예제 #41
0
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            if (flagSelectFeature == true) //选择实体
            {
                axMapControl1.Map.ClearSelection();
                IGeometry geometry = axMapControl1.TrackRectangle();
                IPoint    p1, p2, p3, p4;
                p1 = new PointClass();
                p2 = new PointClass();
                p3 = new PointClass();
                p4 = new PointClass();
                p1.PutCoords(geometry.Envelope.XMin, geometry.Envelope.YMin);
                p2.PutCoords(geometry.Envelope.XMin, geometry.Envelope.YMax);
                p3.PutCoords(geometry.Envelope.XMax, geometry.Envelope.YMax);
                p4.PutCoords(geometry.Envelope.XMax, geometry.Envelope.YMin);
                IGeometryCollection pPolyline = new PolylineClass();
                object o = Type.Missing;

                for (int i = 0; i < 4; i++)
                {
                    IPointCollection pPath = new PathClass();
                    switch (i)
                    {
                    case 0:
                        pPath.AddPoint(p1, ref o, ref o);
                        pPath.AddPoint(p2, ref o, ref o);
                        break;

                    case 1:
                        pPath.AddPoint(p2, ref o, ref o);
                        pPath.AddPoint(p3, ref o, ref o);
                        break;

                    case 2:
                        pPath.AddPoint(p3, ref o, ref o);
                        pPath.AddPoint(p4, ref o, ref o);
                        break;

                    case 3:
                        pPath.AddPoint(p4, ref o, ref o);
                        pPath.AddPoint(p1, ref o, ref o);
                        break;
                    }
                    pPolyline.AddGeometry(pPath as IGeometry, ref o, ref o);
                }
                IGeometry    polyline     = pPolyline as IGeometry;
                ILineElement pLineElement = new LineElementClass();
                rectpElement          = pLineElement as IElement;
                rectpElement.Geometry = polyline;
                IGraphicsContainer graphicsContainer = axMapControl1.ActiveView.GraphicsContainer;
                graphicsContainer.DeleteAllElements();

                graphicsContainer.AddElement(rectpElement, 0);
                axMapControl1.Refresh();

                //创建sptialFilter
                ISpatialFilter spatialFilter = new SpatialFilterClass();
                spatialFilter.Geometry   = geometry;
                spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                int iIndex = 0;
                for (iIndex = 0; iIndex < axMapControl1.LayerCount; iIndex++)
                {
                    ILayer        pLayer  = axMapControl1.get_Layer(iIndex);
                    IFeatureLayer pFLayer = pLayer as IFeatureLayer;
                    IFeatureClass pFClass = pFLayer.FeatureClass;
                    if (pFClass.ShapeType == esriGeometryType.esriGeometryPoint)
                    {
                        IFeatureCursor featureCursor = pFClass.Search(spatialFilter, true);
                        IFeature       pFeature      = featureCursor.NextFeature();
                        while (pFeature != null)
                        {
                            axMapControl1.Map.SelectFeature(pLayer, pFeature);
                            pFeature = featureCursor.NextFeature();
                        }
                        axMapControl1.Refresh();
                    }
                }
                flagSelectFeature = false;
                择测区范围ToolStripMenuItem.Checked = false;
            }
            else if (flagCreateFeature == true) //创建实体
            {
                int iIndex;
                for (iIndex = 0; iIndex < axMapControl1.LayerCount; iIndex++)
                {
                    ILayer        pLayer   = axMapControl1.get_Layer(iIndex);
                    IFeatureLayer pFLayer  = pLayer as IFeatureLayer;
                    IFeatureClass pFClass  = pFLayer.FeatureClass;
                    IGeometry     geometry = null;
                    if (pFClass.ShapeType == esriGeometryType.esriGeometryPoint)
                    {
                        IPoint point = new PointClass();
                        point.PutCoords(e.mapX, e.mapY);
                        geometry = point as IGeometry;
                        IFeature pFeature = pFClass.CreateFeature();
                        pFeature.Shape = geometry;
                        pFeature.Store();

                        axMapControl1.Refresh();
                        flagCreateFeature             = false;
                        除控制点ToolStripMenuItem.Checked = false;
                    }
                }
            }
            else if (flagSelectStation == true)
            {
                axMapControl1.Map.ClearSelection();
                IGeometry      geometry      = axMapControl1.TrackCircle();
                ISpatialFilter spatialFilter = new SpatialFilter();
                spatialFilter.Geometry   = geometry;
                spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;
                int iIndex;
                for (iIndex = 0; iIndex < axMapControl1.LayerCount; iIndex++)
                {
                    ILayer        pLayer  = axMapControl1.get_Layer(iIndex);
                    IFeatureLayer pFLayer = pLayer as IFeatureLayer;
                    IFeatureClass pFClass = pFLayer.FeatureClass;
                    if (pFClass.ShapeType == esriGeometryType.esriGeometryPoint)
                    {
                        IFeatureCursor featureCursor = pFClass.Search(spatialFilter, true);
                        IFeature       pFeature      = featureCursor.NextFeature();
                        while (pFeature != null)
                        {
                            axMapControl1.Map.SelectFeature(pLayer, pFeature);
                            pFeature = featureCursor.NextFeature();
                        }
                        axMapControl1.Refresh();
                        flagSelectStation = false;
                        择当前测站ToolStripMenuItem.Checked = false;
                    }
                }
            }
        }
        public void Refresh()
        {
            //If the selection does not support IGxDataset, do nothing.
            IGxSelection       pSelection     = null;
            IGxObject          pLocation      = null;
            IGraphicsContainer pGraphicsLayer = null;

            try
            {
                pSelection = m_pSelection;
                pLocation  = pSelection.Location;
                if (!(pLocation is IGxDataset))
                {
                    return;
                }

                //Clear the contents of the graphics layer.

                pGraphicsLayer = (IGraphicsContainer)frmExtentView.AxMapControl1.Map.BasicGraphicsLayer;
                pGraphicsLayer.DeleteAllElements();

                //Some dataset may not have content at all
                IGxDataset        pGxDataset        = null;
                IGeoDataset       pGeoDataset       = null;
                IElement          pElement          = null;
                IFillShapeElement pFillShapeElement = null;
                try
                {
                    //Get the geodataset out of the GxDataset.
                    pGxDataset = (IGxDataset)pLocation;
                    if (pGxDataset.Type == esriDatasetType.esriDTLayer |
                        pGxDataset.Type == esriDatasetType.esriDTFeatureClass |
                        pGxDataset.Type == esriDatasetType.esriDTFeatureDataset)
                    {
                        pGeoDataset = (IGeoDataset)pGxDataset.Dataset;
                    }
                    else
                    {
                        return;
                    }

                    //Create a rectangular graphic element to represent the geodataset's full extent.

                    pElement          = new RectangleElement();
                    pElement.Geometry = pGeoDataset.Extent;

                    //Set the element's symbology.

                    pFillShapeElement        = (IFillShapeElement)pElement;
                    pFillShapeElement.Symbol = m_pFillSymbol;

                    //Add the rectangle element to the graphics layer, and force the map to redraw.
                    pGraphicsLayer.AddElement(pElement, 0);
                    frmExtentView.AxMapControl1.Refresh();
                }
                catch (Exception ex)
                {
                    frmExtentView.AxMapControl1.Refresh();
                    throw ex;
                }
                finally
                {
                    pGxDataset        = null;
                    pGeoDataset       = null;
                    pElement          = null;
                    pFillShapeElement = null;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                pSelection     = null;
                pLocation      = null;
                pGraphicsLayer = null;
            }
        }
예제 #43
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication app = DF2DApplication.Application;

            m_ActiveView = app.Current2DMapControl.ActiveView;
            IGraphicsContainer pGC = m_ActiveView.GraphicsContainer;

            if (this.m_ActiveView.FocusMap.FeatureSelection != null)
            {
                this.m_ActiveView.FocusMap.ClearSelection();
            }
            bool ready = false;

            if (app == null || app.Current2DMapControl == null)
            {
                return;
            }
            IGeometry pGeo      = null;
            int       preCount  = 0;
            int       nextCount = 0;

            try
            {
                if (button == 1)
                {
                    PointClass searchPoint = new PointClass();
                    searchPoint.PutCoords(mapX, mapY);
                    pGeo = PublicFunction.DoBuffer(searchPoint,
                                                   PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate));
                    if (pGeo == null)
                    {
                        return;
                    }
                    ready = true;
                    if (ready)
                    {
                        bool haveone = false;
                        foreach (LogicGroup lg in LogicDataStructureManage2D.Instance.RootLogicGroups)
                        {
                            if (haveone)
                            {
                                break;
                            }
                            foreach (MajorClass mc in lg.MajorClasses)
                            {
                                if (haveone)
                                {
                                    break;
                                }
                                string[] arrFc2DId = mc.Fc2D.Split(';');
                                if (arrFc2DId == null)
                                {
                                    continue;
                                }
                                IFeatureCursor pFeatureCursor = null;
                                IFeature       pFeature       = null;
                                //DFDataConfig.Class.FieldInfo fi;
                                //int indexFusu = 0;
                                ////string nodefcId = null;
                                foreach (SubClass sc in mc.SubClasses)
                                {
                                    if (haveone)
                                    {
                                        break;
                                    }
                                    if (!sc.Visible2D)
                                    {
                                        continue;
                                    }
                                    foreach (string fc2DId in arrFc2DId)
                                    {
                                        DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                                        if (dffc == null)
                                        {
                                            continue;
                                        }
                                        IFeatureClass fc   = dffc.GetFeatureClass();
                                        FacilityClass facc = dffc.GetFacilityClass();
                                        if (facc.Name != "PipeLine")
                                        {
                                            continue;
                                        }
                                        ISpatialFilter pSpatialFilter = new SpatialFilter();
                                        pSpatialFilter.Geometry   = pGeo;
                                        pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                                        pFeatureCursor            = fc.Search(pSpatialFilter, false);
                                        if (pFeatureCursor == null)
                                        {
                                            continue;
                                        }
                                        pFeature = pFeatureCursor.NextFeature();
                                        if (pFeature == null)
                                        {
                                            continue;
                                        }
                                        IGeometry pGeometry = pFeature.Shape as IGeometry;
                                        if (pGeometry.GeometryType == esriGeometryType.esriGeometryPolyline)
                                        {
                                            IPolyline pLine = pGeometry as IPolyline;
                                            this._EdgeFCID = fc.FeatureClassID.ToString();
                                            this._EdgeOID  = pFeature.OID;
                                            color          = GetRGBColor(0, 230, 240);
                                            IElement lineElement = LineElementRenderer(pLine, color);
                                            pGC.AddElement(lineElement, 0);
                                        }
                                        haveone = true;
                                        break;
                                    }

                                    foreach (string fc2DId in arrFc2DId)
                                    {
                                        DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                                        if (dffc == null)
                                        {
                                            continue;
                                        }
                                        IFeatureClass fc   = dffc.GetFeatureClass();
                                        FacilityClass facc = dffc.GetFacilityClass();
                                        IFeatureLayer fl   = dffc.GetFeatureLayer();
                                        if (fc == null || pGeo == null || fl == null)
                                        {
                                            continue;
                                        }
                                        if (!fl.Visible)
                                        {
                                            continue;
                                        }
                                        if (facc.Name != "PipeNode")
                                        {
                                            continue;
                                        }
                                        DFDataConfig.Class.FieldInfo fi = facc.GetFieldInfoBySystemName("Additional");
                                        IFields fiCol     = fc.Fields;
                                        int     indexFusu = fiCol.FindField(fi.Name);

                                        WaitForm.Start("正在分析...", "请稍后");
                                        TopoClass2D tc = FacilityInfoService2D.GetTopoClassByFeatureClassID(fc2DId);
                                        if (tc == null)
                                        {
                                            WaitForm.Stop();
                                            return;
                                        }
                                        TopoNetwork net = tc.GetNetwork();
                                        if (net == null)
                                        {
                                            WaitForm.Stop();
                                            XtraMessageBox.Show("构建拓扑网络失败!", "提示");
                                            return;
                                        }
                                        else
                                        {
                                            HashSet <string> valveIds = new HashSet <string>();
                                            if (!string.IsNullOrEmpty(fc2DId) && ValveManager.Instance.Exists(fc2DId))
                                            {
                                                valveIds = ValveManager.Instance.GetValveIds(fc2DId);
                                            }
                                            else
                                            {
                                                IFeature feature;
                                                string   fusu;
                                                //IQueryFilter filter = new QueryFilter();

                                                //filter.WhereClause = fi.Name + " LIKE '%阀%'";
                                                IFeatureCursor cursor = fc.Search(null, false);
                                                int            n      = fc.FeatureCount(null);
                                                if (indexFusu == 0)
                                                {
                                                    return;
                                                }
                                                while ((feature = cursor.NextFeature()) != null)
                                                {
                                                    //valveIds.Add(fc2DId + "_" + feature.OID.ToString());
                                                    fusu = feature.get_Value(indexFusu).ToString();
                                                    if (fusu == "阀门" || fusu == "阀门井")
                                                    {
                                                        valveIds.Add(fc2DId + "_" + feature.OID.ToString());
                                                    }
                                                }
                                                ValveManager.Instance.Add(fc2DId, valveIds);
                                            }
                                            //string edgeID = this._EdgeFCID + "_" + this._EdgeOID.ToString();
                                            if (EdgeManager.Instance.Exists(this._EdgeFCID, this._EdgeOID.ToString()))
                                            {
                                                edge = EdgeManager.Instance.GetEdgeByID(this._EdgeFCID, this._EdgeOID.ToString());
                                            }
                                            preNode  = edge.PreNode;
                                            nextNode = edge.NextNode;
                                            HashSet <string> recordPre  = new HashSet <string>();
                                            HashSet <string> recordNext = new HashSet <string>();
                                            color = GetRGBColor(255, 0, 0);
                                            net.BGFX(preNode.ID, nextNode.ID, valveIds, ref recordPre, ref recordNext);
                                            if (recordPre.Count <= 0 && recordNext.Count <= 0)
                                            {
                                                continue;
                                            }
                                            preCount  = recordPre.Count;
                                            nextCount = recordNext.Count;
                                            foreach (string s in recordPre)
                                            {
                                                int  id;
                                                Node n = NodeManager.Instance.GetNodeByID(s);
                                                Int32.TryParse(n.FeatureId, out id);
                                                IFeature feature = fc.GetFeature(id);
                                                IPoint   point   = feature.Shape as IPoint;
                                                //color = GetRGBColor(255, 0, 0);
                                                IElement elementpPoint = PointElementRenderer(point, color);
                                                pGC.AddElement(elementpPoint, 0);

                                                IElement elementText = AddCallout(app.Current2DMapControl, point, "需关闭阀门", color);
                                                pGC.AddElement(elementText, 1);
                                                app.Current2DMapControl.CenterAt(point);
                                            }
                                            foreach (string s in recordNext)
                                            {
                                                int  id;
                                                Node n = NodeManager.Instance.GetNodeByID(s);
                                                Int32.TryParse(n.FeatureId, out id);
                                                IFeature feature = fc.GetFeature(id);
                                                IPoint   point   = feature.Shape as IPoint;
                                                color = GetRGBColor(0, 0, 0);
                                                IElement elementpPoint = PointElementRenderer(point, color);
                                                pGC.AddElement(elementpPoint, 0);

                                                IElement elementText = AddCallout(app.Current2DMapControl, point, "需关闭阀门", color);
                                                pGC.AddElement(elementText, 1);
                                                app.Current2DMapControl.CenterAt(point);
                                            }
                                            app.Current2DMapControl.MapScale = 500;
                                            app.Current2DMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                                        }
                                        if (haveone)
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
            }
            finally
            {
                WaitForm.Stop();
                XtraMessageBox.Show("上游需关闭阀门:" + preCount + "\n下游需关闭阀门:" + nextCount, "提示");
                SuspendCommand();
            }
        }
예제 #44
0
        public static void setAllElements(Dictionary <string, string> dict)
        {
            IPageLayout        pLayout   = _pMxDoc.PageLayout;
            IGraphicsContainer pGraphics = pLayout as IGraphicsContainer;

            pGraphics.Reset();

            IElement            element = new TextElementClass();
            IElementProperties2 pElementProp;
            ITextElement        pTextElement;

            try
            {
                element = (IElement)pGraphics.Next();
                while (element != null)
                {
                    if (element is ITextElement)
                    {
                        pTextElement = element as ITextElement;
                        pElementProp = element as IElementProperties2;
                        if (pElementProp.Name == "title")
                        {
                            pTextElement.Text = dict["title"];
                        }
                        else if (pElementProp.Name == "summary")
                        {
                            pTextElement.Text = dict["summary"];
                        }
                        else if (pElementProp.Name == "mxd_name")
                        {
                            pTextElement.Text = dict["mxd_name"];
                        }
                        else if (pElementProp.Name == "map_no")
                        {
                            pTextElement.Text = dict["map_no"];
                        }
                        else if (pElementProp.Name == "scale")
                        {
                            pTextElement.Text = dict["scale"];
                        }
                        else if (pElementProp.Name == "spatial_reference")
                        {
                            pTextElement.Text = dict["spatial_reference"];
                        }
                        else if (pElementProp.Name == "glide_no")
                        {
                            pTextElement.Text = dict["glide_no"];
                        }
                    }
                    element = (IElement)pGraphics.Next();
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Error updating layout elements");
                System.Diagnostics.Debug.WriteLine(e);
            }

            IActiveView activeView = _pMxDoc.ActivatedView as IActiveView;

            activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
예제 #45
0
 /// <summary>
 /// 画经纬度格网短线
 /// </summary>
 /// <param name="pFromPoint"></param>
 /// <param name="pToPoint"></param>
 /// <param name="pLine"></param>
 /// <param name="lngMinX"></param>
 /// <param name="lngMinY"></param>
 /// <param name="vType"></param>
 /// <param name="lngScale"></param>
 /// <param name="pMapelement"></param>
 /// <param name="pGrapContainer"></param>
 private void DrawCoordinameGridLine(IPoint pFromPoint, IPoint pToPoint,
                                     ILine pLine, double lngMinX, double lngMinY, int vType, long lngScale, IMapFrame pMapelement, IGraphicsContainer pGrapContainer)
 {
 }
		private void WireGraphicsEvents()
		{
			try
			{
				if (m_naWindowEventSource == null)
					return;

				if (m_graphicsEventSource != null)
					UnWireGraphicsEvents();

				IMap activeMap = ActiveMap;
				IGraphicsLayer graphicsLayer = null;
				if (activeMap != null)
					graphicsLayer = activeMap.BasicGraphicsLayer;

				if (graphicsLayer != null)
					m_graphicsEventSource = (IGraphicsContainer)graphicsLayer;

				if (m_graphicsEventSource == null)
					return;

				UpdateGraphicsEIDArrayParameterValues();

				//Create an instance of the delegate, add it to AllElementsDeleted event
				m_AllGraphicsDeleted = new ESRI.ArcGIS.Carto.IGraphicsContainerEvents_AllElementsDeletedEventHandler(OnAllGraphicsDeleted);
				((ESRI.ArcGIS.Carto.IGraphicsContainerEvents_Event)(m_graphicsEventSource)).AllElementsDeleted += m_AllGraphicsDeleted;

				//Create an instance of the delegate, add it to ElementAdded event
				m_GraphicAdded = new ESRI.ArcGIS.Carto.IGraphicsContainerEvents_ElementAddedEventHandler(OnGraphicAdded);
				((ESRI.ArcGIS.Carto.IGraphicsContainerEvents_Event)(m_graphicsEventSource)).ElementAdded += m_GraphicAdded;

				//Create an instance of the delegate, add it to ElementDeleted event
				m_GraphicDeleted = new ESRI.ArcGIS.Carto.IGraphicsContainerEvents_ElementDeletedEventHandler(OnGraphicDeleted);
				((ESRI.ArcGIS.Carto.IGraphicsContainerEvents_Event)(m_graphicsEventSource)).ElementDeleted += m_GraphicDeleted;

				//Create an instance of the delegate, add it to ElementsAdded event
				m_GraphicsAdded = new ESRI.ArcGIS.Carto.IGraphicsContainerEvents_ElementsAddedEventHandler(OnGraphicsAdded);
				((ESRI.ArcGIS.Carto.IGraphicsContainerEvents_Event)(m_graphicsEventSource)).ElementsAdded += m_GraphicsAdded;

				//Create an instance of the delegate, add it to ElementUpdated event
				m_GraphicUpdated = new ESRI.ArcGIS.Carto.IGraphicsContainerEvents_ElementUpdatedEventHandler(OnGraphicUpdated);
				((ESRI.ArcGIS.Carto.IGraphicsContainerEvents_Event)(m_graphicsEventSource)).ElementUpdated += m_GraphicUpdated;
			}
			catch (Exception ex)
			{
				string msg = SubsetHelperUI.GetFullExceptionMessage(ex);
				MessageBox.Show(msg, "Wire Graphics Events");
			}
		}
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            try
            {
                //get access to the document and the active view
                pMxDocument = (IMxDocument)clsAgrcArcMapExtension.m_application.Document;
                pMap        = pMxDocument.FocusMap;
                pActiveView = pMxDocument.ActiveView;                  //pActiveView = (IActiveView)pMap;

                //get the map's graphics layer
                ICompositeGraphicsLayer2 pComGraphicsLayer = pMap.BasicGraphicsLayer as ICompositeGraphicsLayer2;
                ICompositeLayer          pCompositeLayer   = pComGraphicsLayer as ICompositeLayer;
                ILayer pLayer;

                //loop through all graphic layers in the map and check for the 'PolyVertices' layer, if found, delete it, in order to start fresh
                for (int i = 0; i < pCompositeLayer.Count; i++)
                {
                    pLayer = pCompositeLayer.get_Layer(i);
                    if (pLayer.Name == "PolyVertices")
                    {
                        pComGraphicsLayer.DeleteLayer("PolyVertices");
                        break;
                    }
                }


                if (bolVerticesOn == false)
                {
                    IGraphicsLayer pGraphicsLayer = pComGraphicsLayer.AddLayer("PolyVertices", null);
                    pMap.ActiveGraphicsLayer = (ILayer)pGraphicsLayer;
                    IGraphicsContainer pGraphicsContainer = pComGraphicsLayer.FindLayer("PolyVertices") as IGraphicsContainer;


                    //make sure the user has selected a polygon or polyline layer
                    if (pMxDocument.SelectedLayer == null)
                    {
                        MessageBox.Show("Please select a layer.", "Select Layer", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    if (!(pMxDocument.SelectedLayer is IFeatureLayer))
                    {
                        MessageBox.Show("Please select a polygon or line layer.", "Polygon or Line", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }

                    //cast the selected layer as a feature layer
                    IGeoFeatureLayer pGFlayer = (IGeoFeatureLayer)pMxDocument.SelectedLayer;

                    //check if the feaure layer is a polygon or line layer
                    if (pGFlayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolygon & pGFlayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolyline)
                    {
                        MessageBox.Show("Please select a polygon or line layer.", "Polygon or Line", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }


                    //setup marker symbol
                    ISimpleMarkerSymbol pSimpleMarker = new SimpleMarkerSymbol();
                    ISymbol             pSymbolMarker = (ISymbol)pSimpleMarker;
                    IRgbColor           pRgbColor     = new ESRI.ArcGIS.Display.RgbColorClass();
                    pRgbColor.Red       = 223;
                    pRgbColor.Green     = 155;
                    pRgbColor.Blue      = 255;
                    pSimpleMarker.Color = pRgbColor;
                    pSimpleMarker.Style = esriSimpleMarkerStyle.esriSMSDiamond;
                    pSimpleMarker.Size  = 8;

                    //setup line symbol
                    ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbol();
                    ISymbol           pSymbolLine       = (ISymbol)pSimpleLineSymbol;
                    pRgbColor               = new ESRI.ArcGIS.Display.RgbColor();
                    pRgbColor.Red           = 0;
                    pRgbColor.Green         = 255;
                    pRgbColor.Blue          = 0;
                    pSimpleLineSymbol.Color = pRgbColor;
                    pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
                    pSimpleLineSymbol.Width = 1;

                    //setup simplefill symbol
                    ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbol();
                    ISymbol           pSymbolPolygon    = (ISymbol)pSimpleFillSymbol;
                    pRgbColor               = new ESRI.ArcGIS.Display.RgbColor();
                    pRgbColor.Red           = 0;
                    pRgbColor.Green         = 0;
                    pRgbColor.Blue          = 255;
                    pSimpleFillSymbol.Color = pRgbColor;
                    pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid;

                    //get all the polygons in the current map extent ina cursor
                    IEnvelope      pMapExtent = pActiveView.Extent;
                    ISpatialFilter pQFilter   = new SpatialFilter();
                    pQFilter.GeometryField = "SHAPE";
                    pQFilter.Geometry      = pMapExtent;
                    pQFilter.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects;
                    IFeatureCursor pFCursor = pGFlayer.Search(pQFilter, true);


                    //draw each polygon and then each polygon's point collection
                    IFeature  pFeature = pFCursor.NextFeature();
                    IGeometry pGeometry;

                    while (pFeature != null)
                    {
                        pGeometry = pFeature.Shape;
                        //draw the polygon
                        //draw each vertex on the polygon
                        IPointCollection pPointCollection = pGeometry as IPointCollection;
                        for (int i = 0; i < pPointCollection.PointCount; i++)
                        {
                            IGeometry pPtGeom  = pPointCollection.get_Point(i);
                            IElement  pElement = new MarkerElement();
                            pElement.Geometry = pPtGeom;
                            IMarkerElement pMarkerElement = pElement as IMarkerElement;
                            pMarkerElement.Symbol = pSimpleMarker;
                            pGraphicsContainer.AddElement(pElement, 0);
                        }
                        pFeature = pFCursor.NextFeature();
                    }

                    bolVerticesOn = true;
                }
                else                 //if (bolVerticesOn == true)
                {
                    bolVerticesOn = false;
                }

                //refresh the map
                pActiveView.Refresh();
                pActiveView.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Message: " + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine +
                                "Error Source: " + Environment.NewLine + ex.Source + Environment.NewLine + Environment.NewLine +
                                "Error Location:" + Environment.NewLine + ex.StackTrace,
                                "AGRC Custom Tools ArcMap Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
 /// <summary>
 ///     The draw aoi.
 /// </summary>
 /// <param name="graphicContainer">
 ///     The graphic container.
 /// </param>
 private void DrawAoi(IGraphicsContainer graphicContainer)
 {
     if (this.localElement != null)
     {
         graphicContainer.AddElement(this.localElement, 0);
     }
 }
예제 #49
0
        private void _AddZingers(IFeatureLayer fromLayer, string fromFieldName, IFeatureLayer toLayer, string toFieldName)
        {
            ICompositeGraphicsLayer basicGraphicsLayer = (ICompositeGraphicsLayer)_document.FocusMap.BasicGraphicsLayer;
            string graphicsLayerName = _GetGraphicsLayerName(fromLayer.FeatureClass);

            // Create lookup for "to" points
            Type toValueType;
            Dictionary <object, List <IPoint> > toPoints = _GetToPointLookup(toLayer, toFieldName, out toValueType);

            // Add zingers
            if (toPoints.Count > 0)
            {
                IGraphicsContainer graphics = (IGraphicsContainer)basicGraphicsLayer.AddLayer(graphicsLayerName, fromLayer);
                IFeatureCursor     cursor   = null;
                try
                {
                    int fromField = fromLayer.FeatureClass.FindField(fromFieldName);
                    cursor = fromLayer.FeatureClass.Search(null, false);
                    IFeature fromFeature = cursor.NextFeature();
                    while (fromFeature != null)
                    {
                        try
                        {
                            IPoint fromPoint = _GetFeaturePoint(fromFeature);
                            if (fromPoint != null)
                            {
                                object fromValue = fromFeature.get_Value(fromField);
                                if (fromValue != DBNull.Value)
                                {
                                    try
                                    {
                                        fromValue = Convert.ChangeType(fromValue, toValueType);
                                    }
                                    catch (Exception ex)
                                    {
                                        throw new Exception("Could not convert values in \"from\" field to type of value in \"to\" field.", ex);
                                    }

                                    if (toPoints.ContainsKey(fromValue))
                                    {
                                        foreach (IPoint toPoint in toPoints[fromValue])
                                        {
                                            IPolyline line = new PolylineClass();
                                            line.FromPoint = fromPoint;
                                            line.ToPoint   = toPoint;
                                            IElement element = new LineElementClass();
                                            element.Geometry = line;
                                            ((ILineElement)element).Symbol = _GetZingerSymbol();

                                            graphics.AddElement(element, 0);
                                        }
                                    }
                                }
                            }
                        }
                        finally
                        {
//                            UrbanDelineationExtension.ReleaseComObject(fromFeature);
                        }
                        fromFeature = cursor.NextFeature();
                    }
                }
                finally
                {
//                    UrbanDelineationExtension.ReleaseComObject(cursor);
                }
            }
        }
        /// <summary>
        ///     Draw the polygon contained within the properties.
        /// </summary>
        /// <param name="polyToBeDrawn">
        ///     The polygon to be drawn.
        /// </param>
        /// <param name="graphicContainer">
        ///     The graphic container.
        /// </param>
        private void DrawPoly(Properties polyToBeDrawn, IGraphicsContainer graphicContainer)
        {
            var poly = new PolygonClass();
            poly.Project(ArcMap.Document.ActiveView.Extent.SpatialReference);
            foreach (var pnt in polyToBeDrawn.Points)
            {
                var tempPoint = new PointClass();
                tempPoint.PutCoords(pnt.X, pnt.Y);
                tempPoint.SpatialReference = Jarvis.ProjectedCoordinateSystem;
                tempPoint.Project(ArcMap.Document.ActiveView.Extent.SpatialReference);
                poly.AddPoint(tempPoint);
            }

            IElement elm = new PolygonElementClass();
            elm.Geometry = poly;

            graphicContainer.AddElement(elm, 0);
        }
예제 #51
0
        private void ShowCallout(IPoint loc, string text)
        {
            try
            {
                ITextElement         pTextElement = new TextElementClass();
                IElement             pElement;
                IBalloonCallout      pCallout     = new BalloonCalloutClass();
                IFillSymbol          pFill        = new SimpleFillSymbolClass();
                ILineSymbol          pLine        = new SimpleLineSymbolClass();
                IFormattedTextSymbol pLabelSymbol = new TextSymbolClass();

                IRgbColor c = new RgbColorClass();
                c.Red   = 0;
                c.Green = 0;
                c.Blue  = 0;

                IRgbColor d = new RgbColorClass();
                d.Red   = 255;
                d.Green = 255;
                d.Blue  = 255;

                IRgbColor e = new RgbColorClass();
                e.Red   = 205;
                e.Green = 192;
                e.Blue  = 176;

                pLine.Color   = c;
                pFill.Color   = d;
                pFill.Outline = pLine;

                pCallout.Symbol      = pFill;
                pCallout.Style       = esriBalloonCalloutStyle.esriBCSRoundedRectangle;
                pCallout.AnchorPoint = loc;

                pLabelSymbol.Background    = pCallout as ITextBackground;
                pLabelSymbol.Size          = 10.5d;
                pLabelSymbol.ShadowColor   = e;
                pLabelSymbol.ShadowXOffset = 1.0d;
                pLabelSymbol.ShadowYOffset = 1.0d;

                pTextElement.Text   = text;
                pTextElement.Symbol = pLabelSymbol as ITextSymbol;

                pElement = pTextElement as IElement;
                double delta = (.1 * mMap.MapScale) / 2;
                //switch (mMap.MapScale)
                //{
                //    case
                //}

                IPoint p1 = new PointClass();
                p1.X = loc.X + delta;
                p1.Y = loc.Y + delta;


                pElement.Geometry = p1;



                graphicsContainer = mDoc.ActiveView as IGraphicsContainer;

                graphicsContainer.AddElement(pElement, 0);
                pElement.Activate(mDoc.ActiveView.ScreenDisplay);

                mDoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, pElement, null);
                mMap.ClearSelection();

                Timer t = new Timer();
                t.Interval = 2000;
                t.Tick    += new EventHandler(t_Tick);
                t.Start();
            }
            catch (Exception ex) { log.WriteError(ex, TAG, System.Security.Principal.WindowsIdentity.GetCurrent().Name, null); }
        }
예제 #52
0
 public Size GetDesiredSize(IGraphicsContainer gc, Size limit)
 {
     return Rects.Constrain(new Size(300,400), limit);
 }
예제 #53
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            mMapControl.Map.ClearSelection(); //清除上次查询结果

            ILayer pLayer;

            for (int i = 0; i < this.mMapControl.LayerCount; i++)
            {
                pLayer = this.mMapControl.get_Layer(i);
                if (pLayer.Name == "points")
                {
                    mFeatureLayer = pLayer as IFeatureLayer;
                    break;
                }
            }
            IActiveView        pActiveView = mMapControl.Map as IActiveView;
            IGraphicsContainer pGrap       = pActiveView as IGraphicsContainer;

            pGrap.DeleteAllElements();//清除marker图片

            IQueryFilter pQueryFilter = new QueryFilterClass();

            //设置查询过滤条件
            pQueryFilter.WhereClause = "name = '" + listBox1.Text + "'";
            //查询 ,search的参数第一个为过滤条件,第二个为是否重复执行
            IFeatureCursor pFeatureCursor = mFeatureLayer.Search(pQueryFilter, false);
            //获取查询到的要素
            IFeature pFeature = pFeatureCursor.NextFeature();

            while (pFeature != null)
            {
                mMapControl.Map.SelectFeature(mFeatureLayer, pFeature); //选择要素

                //添加marker
                IColor    pColor;
                IRgbColor pRgbColor = new RgbColorClass();
                pRgbColor.Red   = 255;
                pRgbColor.Green = 255;
                pRgbColor.Blue  = 255;
                pColor          = pRgbColor as IColor;
                IPictureMarkerSymbol pms = new PictureMarkerSymbolClass();
                pms.BitmapTransparencyColor = pColor;
                string picturePath = getPath(path1) + "\\Image\\景点.png";
                //添加自定义站点图片
                pms.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG, picturePath);
                pms.Size = 30;
                IMarkerElement pMarkerEle = new MarkerElementClass();
                pMarkerEle.Symbol = pms as IMarkerSymbol;
                IElement pEle = pMarkerEle as IElement;
                pEle.Geometry = pFeature.Shape as IGeometry;
                pGrap.AddElement(pEle, 1);

                //放大到要素
                IPoint mPoint = pFeature.Shape as IPoint;
                double expand = 0.05;
                ITopologicalOperator mTopoOperator  = mPoint as ITopologicalOperator;
                IPolygon             mPolygonBuffer = mTopoOperator.Buffer(expand) as IPolygon;
                mMapControl.Extent = mPolygonBuffer.Envelope;

                pFeature = pFeatureCursor.NextFeature();
            }
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
            pActiveView.Refresh();//刷新图层

            SetPic(listBox1.Text);
        }
예제 #54
0
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            if(pFlag==1)//缓冲区空间查询
               {
               IActiveView pActView = axMapControl1.Map as IActiveView;

               IPoint pPoint = pActView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);

               ITopologicalOperator pTopo = pPoint as ITopologicalOperator;

               IGeometry pGeo = pTopo.Buffer(500);

               ESRI.ArcGIS.Display.IRgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColorClass();
               rgbColor.Red = 255;

               ESRI.ArcGIS.Display.IColor color = rgbColor; // Implicit Cast
               ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
               simpleFillSymbol.Color = color;

               ESRI.ArcGIS.Display.ISymbol symbol = simpleFillSymbol as ESRI.ArcGIS.Display.ISymbol;

               pActView.ScreenDisplay.SetSymbol(symbol);

               pActView.ScreenDisplay.DrawPolygon(pGeo);

               axMapControl1.Map.SelectByShape(pGeo, null, false);

               axMapControl1.FlashShape(pGeo, 1000, 2, symbol);

               axMapControl1.ActiveView.Refresh();
               }
               if (pFlag == 2)
               {
               pNetMap = axMapControl1.Map;

               pGC = pNetMap as IGraphicsContainer;

               IActiveView pActView = pNetMap as IActiveView;

               IPoint pPoint = pActView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);

               object o = Type.Missing;
               object o1 = Type.Missing;

               pPointC.AddPoint(pPoint, ref o, ref o1);

               IElement Element;

               ITextElement Textelement = new TextElementClass();

               Element = Textelement as IElement;

               pClickedCount++;

               Textelement.Text = pClickedCount.ToString();

               Element.Geometry = pActView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);

               pGC.AddElement(Element, 0);

               pActView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

               IFeatureClass pFeatureClass = pNaContext.NAClasses.get_ItemByName("Stops") as IFeatureClass;

               NASolve(pNaContext, pFeatureClass, pPointC, 5000);

               IGPMessages gpMessages = new GPMessagesClass();

               bool pBool = pNASolveClass.Solve(pNaContext, gpMessages, null);

               }

               if (pFlag == 3)//有向网络
               {
               IWorkspace pWs = GetMDBWorkspace(@".\data\Geometric.mdb");

               IFeatureWorkspace pFtWs = pWs as IFeatureWorkspace;

               IFeatureDataset pFtDataset = pFtWs.OpenFeatureDataset("work");

               double s = 0;

               IPolyline pPolyline = new PolylineClass();

               SolvePath(axMapControl1.Map, GetGeometricNetwork(pFtDataset, "TestGeometric"), "Weight", pPointC, 1000, ref pPolyline, ref s);

               IRgbColor pColor = new RgbColorClass();
               pColor.Red = 255;
               IElement pElement = new LineElementClass();
               ILineSymbol linesymbol = new SimpleLineSymbolClass();
               linesymbol.Color = pColor as IColor;
               linesymbol.Width = 100;

               pElement.Geometry = pPolyline;

               pGC.AddElement(pElement, 2);

               axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
               }
               if (pFlag == 4)
               {
               if(axMapControl1.Map.get_Layer(0)!=null)
               {
                   IRasterLayer pRasterLayer = axMapControl1.Map.get_Layer(0) as IRasterLayer;

                   IRasterSurface pRasterSurface = new RasterSurfaceClass();

                   pRasterSurface.PutRaster(pRasterLayer.Raster, 0);

                   ISurface pSurface = pRasterSurface as ISurface;

                  IPolyline pPolyline = axMapControl1.TrackLine() as  IPolyline;

                   IPoint pPoint =null ;

                    IPolyline pVPolyline =null;

                   IPolyline pInPolyline= null;

                   object pRef=0.13;

                   bool pBool =true;

                   double pZ1 = pSurface.GetElevation(pPolyline.FromPoint);

                   double pZ2= pSurface.GetElevation(pPolyline.ToPoint);

                   IPoint pPoint1 = new PointClass();

                   pPoint1.Z = pZ1;

                   pPoint1.X = pPolyline.FromPoint.X;

                   pPoint1.Y = pPolyline.FromPoint.Y;

                   IPoint pPoint2 = new PointClass();

                   pPoint2.Z = pZ2;

                   pPoint2.X = pPolyline.ToPoint.X;

                   pPoint2.Y = pPolyline.ToPoint.Y;

                   pSurface.GetLineOfSight(pPoint1, pPoint2, out pPoint, out pVPolyline,
                       out pInPolyline, out pBool, false, false, ref pRef);//大爷的,设置为true居然通不过bApplyCurvature和bApplyRefraction两项设置为true,surface必须定义成具有ZUnits的投影坐标

                   //This member should not be used in .NET. As a substitute, .NET developers must use IGeoDatabaseBridge2.GetLineOfSight.

                         //楼主,用IGeoDatabaseBridge2.GetLineOfSight.方法试试
                   if (pVPolyline != null)
                   {

                       IElement pLineElementV = new LineElementClass();

                       pLineElementV.Geometry = pVPolyline;

                       ILineSymbol pLinesymbolV = new SimpleLineSymbolClass();

                       pLinesymbolV.Width = 2;

                       IRgbColor pColorV = new RgbColorClass();

                       pColorV.Green =255;

                       pLinesymbolV.Color = pColorV;

                       ILineElement pLineV = pLineElementV as ILineElement;

                       pLineV.Symbol = pLinesymbolV;

                       axMapControl1.ActiveView.GraphicsContainer.AddElement(pLineElementV, 0);
                   }

                   if (pInPolyline != null)
                   {

                       IElement pLineElementIn = new LineElementClass();

                       pLineElementIn.Geometry = pInPolyline;

                       ILineSymbol pLinesymbolIn = new SimpleLineSymbolClass();

                       pLinesymbolIn.Width = 2;

                       IRgbColor pColorIn = new RgbColorClass();
                       pColorIn.Red = 255;

                       pLinesymbolIn.Color = pColorIn;
                       ILineElement pLineIn = pLineElementIn as ILineElement;

                       pLineIn.Symbol = pLinesymbolIn;

                       axMapControl1.ActiveView.GraphicsContainer.AddElement(pLineElementIn, 1);

                   }

                   axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

                   axMapControl1.TrackCancel.Cancel();

               }
               }
        }