Example #1
0
 public override void OnMouseDown(int Button, int Shift, int X, int Y)
 {
     try
     {
         ClsMarkDraw.DeleteAllElementsWithName(m_hookHelper.FocusMap, sPolyOutlineName);
         ESRI.ArcGIS.Geometry.IPoint pMapPoint = new ESRI.ArcGIS.Geometry.PointClass();
         m_hookHelper.FocusMap.SpatialReference = m_psurface.Domain.SpatialReference;
         pMapPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
         if (pMapPoint == null)
         {
             return;
         }
         pMapPoint.Project(m_psurface.Domain.SpatialReference);
         pMapPoint.Z = m_psurface.GetElevation(pMapPoint);
         IGroupElement pGroup = null;
         ClsMarkDraw.AddSimpleGraphic(pMapPoint, ClsMarkDraw.getRGB(71, 61, 255), 3, sPolyOutlineName, m_hookHelper.FocusMap, pGroup);
         m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
         m_Geometry = pMapPoint;
         EndDtrawd(true);
     }
     catch
     {
         return;
     }
 }
Example #2
0
        public void Init(IActiveView pAv, IPoint pt)
        {
            JLKLegendAssiatant jLKLegendAssiatant = new JLKLegendAssiatant();

            jLKLegendAssiatant.LoadXml(this.m_LegendInfo);
            IEnvelope envelopeClass = new Envelope() as IEnvelope;
            IPoint    upperLeft     = null;

            if (this.m_pGroupElement != null)
            {
                envelopeClass = this.Geometry.Envelope;
                if (!envelopeClass.IsEmpty)
                {
                    upperLeft = envelopeClass.UpperLeft;
                }
            }
            if (upperLeft == null)
            {
                IPoint pointClass = new Point()
                {
                    X = pt.X,
                    Y = pt.Y
                } as IPoint;
                upperLeft = pointClass;
            }
            this.m_pGroupElement = jLKLegendAssiatant.CreateElement(pAv, pt) as IGroupElement;
            envelopeClass        = this.Geometry.Envelope;
            if ((envelopeClass.IsEmpty ? false : pt != null))
            {
                IEnvelope envelope = new Envelope() as IEnvelope;
                envelope.PutCoords(upperLeft.X, upperLeft.Y - envelopeClass.Height, upperLeft.X + envelopeClass.Width,
                                   upperLeft.Y);
            }
        }
Example #3
0
 private void SetMapSurroundFrameMapGroupRecursion(IGroupElement pGroupElement, IMap pMap)
 {
     try
     {
         if (((pGroupElement != null) && (pGroupElement.ElementCount > 0)) && (pMap != null))
         {
             IEnumElement elements = null;
             elements = pGroupElement.Elements;
             elements.Reset();
             IMapSurroundFrame frame    = null;
             IElement          element2 = null;
             for (element2 = elements.Next(); element2 != null; element2 = elements.Next())
             {
                 if (element2 is IMapSurroundFrame)
                 {
                     frame = element2 as IMapSurroundFrame;
                     frame.MapSurround.Map = pMap;
                 }
                 else if (element2 is IGroupElement)
                 {
                     this.SetMapSurroundFrameMapGroupRecursion(element2 as IGroupElement, pMap);
                 }
             }
         }
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.ElementFun", "SetMapSurroundFrameMapGroupRecursion", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
     }
 }
Example #4
0
        /// <summary>
        /// 从组合元素中查找元素,被查找的元素不是组合元素
        /// </summary>
        /// <param name="groupElement"></param>
        /// <param name="elementName"></param>
        /// <returns></returns>
        public static IElement GetFirstElementByName(this IGroupElement groupElement, string elementName)
        {
            IElement     resultElement = null;
            IEnumElement enumEle       = groupElement.Elements;
            IElement     tmpEle;

            while ((tmpEle = enumEle.Next()) != null)
            {
                if ((tmpEle as IGroupElement) != null)
                {
                    resultElement = GetFirstElementByName(tmpEle as IGroupElement, elementName);
                    if (resultElement != null)
                    {
                        break;
                    }
                }
                else
                {
                    if ((tmpEle as IElementProperties)?.Name == elementName)
                    {
                        resultElement = tmpEle;
                        break;
                    }
                }
            }
            return(resultElement);
        }
Example #5
0
 private void InsertMapFrameToTree(IElement pElement, TOCTreeNodeCollection pParantNodes)
 {
     if (pElement is IMapFrame)
     {
         IMapFrame frame = (IMapFrame)pElement;
         string    name  = frame.Map.Name;
         if (name == "")
         {
             name = "Scene";
         }
         TOCTreeNode pNode  = new TOCTreeNodeEx(name, false, true);
         Bitmap      bitmap =
             new Bitmap(
                 base.GetType()
                 .Assembly.GetManifestResourceStream("Yutai.ArcGIS.Controls.Controls.TOCTreeview.layers.bmp"));
         pNode.Image = bitmap;
         pNode.Tag   = frame;
         pParantNodes.Add(pNode);
         this.InsertMapToTree((IBasicMap)frame.Map, pNode);
     }
     else if (pElement is IGroupElement)
     {
         IGroupElement element  = (IGroupElement)pElement;
         IEnumElement  elements = element.Elements;
         elements.Reset();
         for (IElement element3 = elements.Next(); element3 != null; element3 = elements.Next())
         {
             this.InsertMapFrameToTree(element3, pParantNodes);
         }
     }
 }
Example #6
0
        /// <summary>
        /// 从组中删除所有元素
        /// </summary>
        /// <param name="groupElement"></param>
        void RemoveElementFromGroupElement(IGroupElement groupElement)
        {
            if (groupElement == null || groupElement.ElementCount == 0)
            {
                return;
            }
            try
            {
                IGraphicsContainer g = m_hookHelper.ActiveView.GraphicsContainer;
                for (int index = 0; index < groupElement.ElementCount; index++)
                {
                    IElement tmp_Ele = groupElement.get_Element(index);
                    if (tmp_Ele is IGroupElement)
                    {
                        RemoveElementFromGroupElement(tmp_Ele as IGroupElement);
                    }
                    else
                    {
                        try
                        {
                            groupElement.DeleteElement(tmp_Ele);
                        }
                        catch
                        {
                        }
                        finally
                        {
                            tmp_Ele = null;
                        }
                    }
                }
                //groupElement.ClearElements();
            }
            catch
            { }
            finally
            {
                //刷新
                IEnvelope pEnvBounds = null;

                //获取上一次轨迹线的范围,以便确定刷新范围
                try
                {
                    if (m_TraceLine != null)
                    {
                        m_TraceLine.QueryEnvelope(pEnvBounds);
                        pEnvBounds.Expand(4, 4, true); //矩形框向四周扩大4倍(大于2倍就行),目的是为了保证有充足的刷新区域
                    }
                    else
                    {
                        pEnvBounds = m_hookHelper.ActiveView.Extent;
                    }
                }
                catch
                {
                    pEnvBounds = m_hookHelper.ActiveView.Extent;
                }
                m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, pEnvBounds);
            }
        }
Example #7
0
 /// <summary>
 /// 显示轮廓线   张琪  20110629
 /// </summary>
 /// <param name="pPolygon"></param>
 private void ShowCountour(IPolygon pPolygon)
 {
     SysCommon.CProgress vProgress = new SysCommon.CProgress("进度条");
     try
     {
         Cls3DMarkDraw.DeleteAllElementsWithName(m_pCurrentSceneControl.Scene, ContourName);
         if (!chkShowContour.Checked)
         {
             m_pCurrentSceneControl.SceneGraph.RefreshViewers();
             return;
         }
         vProgress.EnableCancel    = false;//设置进度条
         vProgress.ShowDescription = true;
         vProgress.FakeProgress    = true;
         vProgress.TopMost         = true;
         vProgress.ShowProgress();
         vProgress.SetProgress("正在绘制轮廓线");
         ITopologicalOperator pTopo     = pPolygon as ITopologicalOperator;
         IGeometry            pPolyLine = new PolylineClass();
         pPolyLine = pTopo.Boundary;
         object StepSize = Type.Missing;;
         m_SurFace.InterpolateShape(pPolyLine as IGeometry, out pPolyLine, ref StepSize);
         IGroupElement pGroup = null;
         //用于绘制三维效果
         Cls3DMarkDraw.AddSimpleGraphic(pPolyLine as IGeometry, Cls3DMarkDraw.getRGB(30, 255, 255), 4, ContourName, m_pCurrentSceneControl.Scene, pGroup);
         m_pCurrentSceneControl.SceneGraph.RefreshViewers();
         vProgress.Close();
     }
     catch
     {
         vProgress.Close();
     }
 }
Example #8
0
        private static IMapFrame FindFocusMapFrame(IGroupElement igroupElement_0, IMap imap_0)
        {
            IEnumElement elements = igroupElement_0.Elements;

            elements.Reset();
            for (IElement element2 = elements.Next(); element2 != null; element2 = elements.Next())
            {
                if (element2 is IMapFrame)
                {
                    if (imap_0 == (element2 as IMapFrame).Map)
                    {
                        return(element2 as IMapFrame);
                    }
                }
                else if (element2 is IGroupElement)
                {
                    IMapFrame frame2 = FindFocusMapFrame(element2 as IGroupElement, imap_0);
                    if (frame2 != null)
                    {
                        return(frame2);
                    }
                }
            }
            return(null);
        }
Example #9
0
        private int FindElement(IGroupElement pGroupElement, IElement pElement)
        {
            int num;

            if (pElement != null)
            {
                int num1 = 0;
                while (num1 < pGroupElement.ElementCount)
                {
                    if (pGroupElement.Element[num1] != pElement)
                    {
                        num1++;
                    }
                    else
                    {
                        num = num1;
                        return(num);
                    }
                }
                num = -1;
            }
            else
            {
                num = -1;
            }
            return(num);
        }
Example #10
0
        /// <summary>
        /// Subtracts the right group element from the left one: Left+(-Right)
        /// </summary>
        /// <param name="Left">Left element.</param>
        /// <param name="Right">Right element.</param>
        /// <returns>Result, if understood, null otherwise.</returns>
        public override sealed IGroupElement RightSubtract(IGroupElement Left, IGroupElement Right)
        {
            IAbelianGroupElement L = Left as IAbelianGroupElement;
            IAbelianGroupElement R = Right as IAbelianGroupElement;

            if (L is null || R is null)
            {
                return(base.RightSubtract(Left, Right));
            }
Example #11
0
 public MapTemplateGroupElement(int int_1, MapTemplate mapTemplate_1) : base(int_1, mapTemplate_1)
 {
     this.igroupElement_0        = new GroupElementClass();
     base.MapTemplateElementType = MapTemplateElementType.MyGruopElement;
     base.Name = "扩展组合元素";
     base.ElementLocation.LocationType = LocationType.LeftLower;
     this.SizeStyle = MapCartoTemplateLib.SizeStyle.SameAsInsideWidth;
     this.SizeScale = 1.0;
 }
Example #12
0
 public static void RemoveGroupElement(IGroupElement igroupElement_0, ISceneGraph isceneGraph_0)
 {
     if (igroupElement_0.ElementCount > 0)
     {
         igroupElement_0.ClearElements();
         IGraphicsContainer3D graphicsContainer3D = isceneGraph_0.Scene.BasicGraphicsLayer as IGraphicsContainer3D;
         graphicsContainer3D.DeleteElement(igroupElement_0 as IElement);
     }
 }
Example #13
0
 /// <summary>
 ///     Creates an <see cref="IEnumerable{T}" /> from an <see cref="IElement" />
 /// </summary>
 /// <param name="source">An <see cref="IGroupElement" /> to create an <see cref="IEnumerable{T}" /> from.</param>
 /// <returns>An <see cref="IEnumerable{T}" /> that contains the layers from the input source.</returns>
 public static IEnumerable <IElement> AsEnumerable(this IGroupElement source)
 {
     if (source != null)
     {
         for (int i = 0; i < source.ElementCount; i++)
         {
             yield return(source.Element[i]);
         }
     }
 }
 private void OnEntityParentChanged(IGroupElement item, IGroup oldParent, IGroup newParent)
 {
     if (item is IEntity entity)
     {
         var row = GetRow(entity);
         if (row != null)
         {
             row["Parent"].Value = newParent?.Name ?? string.Empty;
         }
     }
 }
Example #15
0
 /// <summary>
 /// 显示参考面     张琪    20110629
 /// </summary>
 /// <param name="pPoly">参考多边形</param>
 private void ShowRefPlane(IPolygon pPoly)
 {
     SysCommon.CProgress vProgress = new SysCommon.CProgress("进度条");
     try
     {
         IGeometry pBoundary = new PolylineClass();
         pBoundary = null;
         IGeometry pPolygon = new PolygonClass();
         pPolygon = null;
         object StepSize = Type.Missing;
         m_SurFace.InterpolateShape(pPoly as IGeometry, out pPolygon, ref StepSize);
         Cls3DMarkDraw.DeleteAllElementsWithName(m_pCurrentSceneControl.Scene, sRefPlaneName); //清除已有的参考面
         if (!chkShowLWRP.Checked)                                                             //当为false时不显示参考面
         {
             m_pCurrentSceneControl.SceneGraph.RefreshViewers();
             return;
         }
         vProgress.EnableCancel    = false;//设置进度条
         vProgress.ShowDescription = true;
         vProgress.FakeProgress    = true;
         vProgress.TopMost         = true;
         vProgress.ShowProgress();
         vProgress.SetProgress("正在绘制参考面");
         ITopologicalOperator pTopo = pPolygon as ITopologicalOperator;
         pBoundary = pTopo.Boundary as IPolyline;
         //设置Z值方向显示
         IZAware pZAware = pBoundary as IZAware;
         pZAware.ZAware = true;
         m_SurFace.InterpolateShape(pBoundary as IGeometry, out pBoundary, ref StepSize);
         m_SurFace.InterpolateShape(pPoly as IGeometry, out pPolygon, ref StepSize);
         IExtrude pExtrude = new GeometryEnvironmentClass();
         //获取参考面的多面体
         IMultiPatch pMultiPatchRefPlaneWall = pExtrude.ExtrudeAbsolute(Convert.ToDouble(txtPlaneHeight.Text), pBoundary as IGeometry) as IMultiPatch;
         pMultiPatchRefPlaneWall.SpatialReference = m_pCurrentSceneControl.Scene.SpatialReference;
         IZ pZ;
         pZAware        = pPolygon as IZAware;
         pZAware.ZAware = true;
         pZ             = pPolygon as IZ;
         pZ.SetConstantZ(Convert.ToDouble(txtPlaneHeight.Text));
         //用于绘制三维效果
         IGroupElement pGroup = null;
         Cls3DMarkDraw.AddSimpleGraphic(pMultiPatchRefPlaneWall as IGeometry, Cls3DMarkDraw.getRGB(71, 61, 255), 1, sRefPlaneName, m_pCurrentSceneControl.Scene, pGroup);
         Cls3DMarkDraw.AddSimpleGraphic(pPolygon as IGeometry, Cls3DMarkDraw.getRGB(71, 61, 255), 1, sRefPlaneName, m_pCurrentSceneControl.Scene, pGroup);
         m_pCurrentSceneControl.SceneGraph.RefreshViewers();
         vProgress.Close();
     }
     catch
     {
         vProgress.Close();
     }
 }
Example #16
0
        /// <summary>
        /// Subtracts the left group element from the right one: (-Left)+Right.
        /// </summary>
        /// <param name="Left">Left element.</param>
        /// <param name="Right">Right element.</param>
        /// <returns>Result, if understood, null otherwise.</returns>
        public override sealed IGroupElement LeftSubtract(IGroupElement Left, IGroupElement Right)
        {
            IAbelianGroupElement L = Left as IAbelianGroupElement;
            IAbelianGroupElement R = Right as IAbelianGroupElement;

            if (L == null || R == null)
            {
                return(base.LeftSubtract(Left, Right));
            }
            else
            {
                return(this.Subtract(R, L));
            }
        }
        private bool CheckParentRecursively([NotNull] IGroup parent, [NotNull] IGroupElement child)
        {
            bool result = false;

            if (child.Parent == parent)
            {
                result = true;
            }
            else if (child.Parent is IGroupElement parentGroup)
            {
                result = CheckParentRecursively(parent, parentGroup);
            }

            return(result);
        }
Example #18
0
 public static void AddGroupElementsToBasicGraphicsLayer(List <IElement> list_0)
 {
     try
     {
         IGraphicsContainer3D graphicsContainer3D = null;
         for (int i = 0; i < list_0.Count; i++)
         {
             IGroupElement groupElement = list_0[i] as IGroupElement;
             graphicsContainer3D.AddElement(groupElement as IElement);
         }
     }
     catch
     {
     }
 }
Example #19
0
 public static void AddGroupElements(IGraphicsContainer3D igraphicsContainer3D_0, List <IElement> list_0)
 {
     try
     {
         int graphicsLayerIndex = BuildingProperty.GetGraphicsLayerIndex(igraphicsContainer3D_0);
         for (int i = 0; i < list_0.Count; i++)
         {
             IGroupElement groupElement = list_0[i] as IGroupElement;
             igraphicsContainer3D_0.AddElement(groupElement as IElement);
             BuildingProperty.AddElement(graphicsLayerIndex, groupElement as IElement);
         }
     }
     catch
     {
     }
 }
Example #20
0
 private IMapFrame GetMapFrameGroupRecursion(IGroupElement pGroupElement, string sMapClassifyName, string sMapName)
 {
     try
     {
         if (pGroupElement != null)
         {
             if (pGroupElement.ElementCount <= 0)
             {
                 return(null);
             }
             IEnumElement elements = null;
             elements = pGroupElement.Elements;
             elements.Reset();
             IMapFrame frame    = null;
             IElement  element2 = null;
             for (element2 = elements.Next(); element2 != null; element2 = elements.Next())
             {
                 if (element2 is IMapFrame)
                 {
                     frame = element2 as IMapFrame;
                     IElementProperties properties = null;
                     properties = frame as IElementProperties;
                     if ((Strings.LCase(Strings.Mid(Convert.ToString(properties.CustomProperty), 4)) == Strings.LCase(sMapClassifyName)) && (string.IsNullOrEmpty(sMapName) | (frame.Map.Name == sMapName)))
                     {
                         return(frame);
                     }
                 }
                 else if (element2 is IGroupElement)
                 {
                     frame = this.GetMapFrameGroupRecursion(element2 as IGroupElement, sMapClassifyName, sMapName);
                     if (frame != null)
                     {
                         return(frame);
                     }
                 }
             }
         }
         return(null);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.ElementFun", "GetMapFrameGroupRecursion", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(null);
     }
 }
Example #21
0
        public void Create(IEnumElement ienumElement_0)
        {
            ienumElement_0.Reset();
            IElement element = ienumElement_0.Next();

            if (this.igroupElement_0 == null)
            {
                this.igroupElement_0 = new GroupElementClass();
            }
            while (element != null)
            {
                this.igroupElement_0.AddElement((element as IClone).Clone() as IElement);
                element = ienumElement_0.Next();
            }
            if ((this.igroupElement_0 as IElement).Geometry.Envelope.IsEmpty)
            {
            }
        }
Example #22
0
        /// <summary>
        /// 从组合元素中获取所有子元素(包括所有层级的子元素,但不包括组合元素本身)
        /// </summary>
        /// <param name="groupElement">组合元素</param>
        /// <returns></returns>
        public static List <IElement> GetElements(this IGroupElement groupElement)
        {
            List <IElement> elementList = new List <IElement>();
            IEnumElement    enumEle     = groupElement.Elements;
            IElement        tmpEle;

            while ((tmpEle = enumEle.Next()) != null)
            {
                if ((tmpEle as IGroupElement) != null)
                {
                    elementList.AddRange(GetElements(tmpEle as IGroupElement));
                }
                else
                {
                    elementList.Add(tmpEle);
                }
            }
            return(elementList);
        }
Example #23
0
        /// <summary>
        /// 初始化变量
        /// </summary>
        void Init()
        {
            //初始化
            m_Elements      = new GroupElementClass();
            m_TraceElement  = new GroupElementClass();
            m_VertexElement = new GroupElementClass();
            m_LabelElement  = new GroupElementClass();

            //初始化,并添加到GraphicsContainer
            IGraphicsContainer graphicsContainer = m_hookHelper.ActiveView as IGraphicsContainer;

            graphicsContainer.AddElement(m_Elements as IElement, 0);
            graphicsContainer.AddElement(m_TraceElement as IElement, 0);
            graphicsContainer.AddElement(m_VertexElement as IElement, 0);
            graphicsContainer.AddElement(m_LabelElement as IElement, 0);

            //添加到m_Elements中
            graphicsContainer.MoveElementToGroup(m_VertexElement as IElement, m_Elements);
            graphicsContainer.MoveElementToGroup(m_LabelElement as IElement, m_Elements);
            graphicsContainer.MoveElementToGroup(m_TraceElement as IElement, m_Elements);
        }
Example #24
0
        public static IElement FindElementByType(IGroupElement igroupElement_0, string string_0)
        {
            IEnumElement elements = igroupElement_0.Elements;

            elements.Reset();
            for (IElement element2 = elements.Next(); element2 != null; element2 = elements.Next())
            {
                if ((element2 is IElementProperties) && ((element2 as IElementProperties).Type == "外框"))
                {
                    return(element2);
                }
                if (element2 is IGroupElement)
                {
                    IElement element4 = FindElementByType(element2 as IGroupElement, string_0);
                    if (element4 != null)
                    {
                        return(element4);
                    }
                }
            }
            return(null);
        }
Example #25
0
        public IElement FindElementByType(IGroupElement igroupElement, string typeName)
        {
            IEnumElement elements = igroupElement.Elements;

            elements.Reset();
            for (IElement element2 = elements.Next(); element2 != null; element2 = elements.Next())
            {
                if ((element2 is IElementProperties) && ((element2 as IElementProperties).Type == typeName))
                {
                    return(element2);
                }
                if (element2 is IGroupElement)
                {
                    IElement element4 = this.FindElementByType(element2 as IGroupElement, typeName);
                    if (element4 != null)
                    {
                        return(element4);
                    }
                }
            }
            return(null);
        }
Example #26
0
 private long SetMapFrameClassifyGroupRecursion(IGroupElement pGroupElement, ref IMapFrame pMapFrame, ref IMapFrame pMapFrameMain)
 {
     try
     {
         if (pGroupElement == null)
         {
             return(0L);
         }
         if (pGroupElement.ElementCount <= 0)
         {
             return(0L);
         }
         IEnumElement elements = null;
         elements = pGroupElement.Elements;
         elements.Reset();
         long     num      = 0L;
         IElement element2 = null;
         for (element2 = elements.Next(); element2 != null; element2 = elements.Next())
         {
             if (element2 is IMapFrame)
             {
                 num      += 1L;
                 pMapFrame = (IMapFrame)element2;
                 this.SetMapFrameClassifyProcess(pMapFrame, ref pMapFrameMain);
             }
             else if (element2 is IGroupElement)
             {
                 num += this.SetMapFrameClassifyGroupRecursion(element2 as IGroupElement, ref pMapFrame, ref pMapFrameMain);
             }
         }
         return(num);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.ElementFun", "SetMapFrameClassifyGroupRecursion", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(-1L);
     }
 }
Example #27
0
 private void SetMapFrameMapGroupRecursion(IGroupElement pGroupElement, string sMapClassifyName, IMap pMap, bool bClearElements)
 {
     try
     {
         if (((pGroupElement != null) && (pGroupElement.ElementCount > 0)) && (pMap != null))
         {
             IEnumElement elements = null;
             elements = pGroupElement.Elements;
             elements.Reset();
             IMapFrame frame    = null;
             IElement  element2 = null;
             for (element2 = elements.Next(); element2 != null; element2 = elements.Next())
             {
                 if (element2 is IMapFrame)
                 {
                     frame = element2 as IMapFrame;
                     IElementProperties properties = null;
                     properties = frame as IElementProperties;
                     if (Strings.LCase(Strings.Mid(Convert.ToString(properties.CustomProperty), 4)) == Strings.LCase(sMapClassifyName))
                     {
                         IMap pTargetMap = frame.Map;
                         GISFunFactory.CoreFun.SyncMapObject(pMap, ref pTargetMap, bClearElements);
                         frame.Map = pTargetMap;
                     }
                 }
                 else if (element2 is IGroupElement)
                 {
                     this.SetMapFrameMapGroupRecursion(element2 as IGroupElement, sMapClassifyName, pMap, bClearElements);
                 }
             }
         }
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.ElementFun", "SetMapFrameMapGroupRecursion", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
     }
 }
Example #28
0
 private void GetMapFrameCollGroupRecursion(IGroupElement pGroupElement, string sMapClassifyName, Collection pMapColl)
 {
     try
     {
         if (((pGroupElement != null) && (pGroupElement.ElementCount > 0)) && (pMapColl != null))
         {
             IEnumElement elements = null;
             elements = pGroupElement.Elements;
             elements.Reset();
             IElement item = null;
             for (item = elements.Next(); item != null; item = elements.Next())
             {
                 if (item is IMapFrame)
                 {
                     IElementProperties properties = null;
                     properties = item as IElementProperties;
                     if (string.IsNullOrEmpty(sMapClassifyName))
                     {
                         pMapColl.Add(item, "", null, null);
                     }
                     else if (Strings.LCase(Strings.Mid(Convert.ToString(properties.CustomProperty), 4)) == Strings.LCase(sMapClassifyName))
                     {
                         pMapColl.Add(item, "", null, null);
                     }
                 }
                 else if (item is IGroupElement)
                 {
                     this.GetMapFrameCollGroupRecursion(item as IGroupElement, sMapClassifyName, pMapColl);
                 }
             }
         }
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.ElementFun", "GetMapFrameCollGroupRecursion", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
     }
 }
Example #29
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();
            }
        }
Example #30
0
        /// <summary>
        /// Subtracts the right operand from the left one.
        /// </summary>
        /// <param name="Left">Left operand.</param>
        /// <param name="Right">Right operand.</param>
        /// <param name="Node">Node performing the operation.</param>
        /// <returns>Result</returns>
        public static IElement EvaluateSubtraction(IElement Left, IElement Right, ScriptNode Node)
        {
            IGroupElement LE = Left as IGroupElement;
            IGroupElement RE = Right as IGroupElement;
            IElement      Result;
            IGroupElement Temp;

            if (LE != null && RE != null)
            {
                Temp = RE.Negate();
                if (Temp != null)
                {
                    Result = LE.AddRight(Temp);
                    if (Result != null)
                    {
                        return(Result);
                    }

                    Result = Temp.AddLeft(LE);
                    if (Result != null)
                    {
                        return(Result);
                    }
                }
            }

            if (Left.IsScalar)
            {
                if (Right.IsScalar)
                {
                    ISet LeftSet  = Left.AssociatedSet;
                    ISet RightSet = Right.AssociatedSet;

                    if (!LeftSet.Equals(RightSet))
                    {
                        if (!Expression.Upgrade(ref Left, ref LeftSet, ref Right, ref RightSet, Node))
                        {
                            throw new ScriptRuntimeException("Incompatible operands.", Node);
                        }

                        LE = Left as IGroupElement;
                        RE = Right as IGroupElement;
                        if (LE != null && RE != null)
                        {
                            Temp = RE.Negate();
                            if (Temp != null)
                            {
                                Result = LE.AddRight(Temp);
                                if (Result != null)
                                {
                                    return(Result);
                                }

                                Result = Temp.AddLeft(LE);
                                if (Result != null)
                                {
                                    return(Result);
                                }
                            }
                        }
                    }

                    throw new ScriptRuntimeException("Operands cannot be subtracted.", Node);
                }
                else
                {
                    LinkedList <IElement> Elements = new LinkedList <IElement>();

                    foreach (IElement RightChild in Right.ChildElements)
                    {
                        Elements.AddLast(EvaluateSubtraction(Left, RightChild, Node));
                    }

                    return(Right.Encapsulate(Elements, Node));
                }
            }
            else
            {
                if (Right.IsScalar)
                {
                    LinkedList <IElement> Elements = new LinkedList <IElement>();

                    foreach (IElement LeftChild in Left.ChildElements)
                    {
                        Elements.AddLast(EvaluateSubtraction(LeftChild, Right, Node));
                    }

                    return(Left.Encapsulate(Elements, Node));
                }
                else
                {
                    ICollection <IElement> LeftChildren  = Left.ChildElements;
                    ICollection <IElement> RightChildren = Right.ChildElements;

                    if (LeftChildren.Count == RightChildren.Count)
                    {
                        LinkedList <IElement>  Elements = new LinkedList <IElement>();
                        IEnumerator <IElement> eLeft    = LeftChildren.GetEnumerator();
                        IEnumerator <IElement> eRight   = RightChildren.GetEnumerator();

                        try
                        {
                            while (eLeft.MoveNext() && eRight.MoveNext())
                            {
                                Elements.AddLast(EvaluateSubtraction(eLeft.Current, eRight.Current, Node));
                            }
                        }
                        finally
                        {
                            eLeft.Dispose();
                            eRight.Dispose();
                        }

                        return(Left.Encapsulate(Elements, Node));
                    }
                    else
                    {
                        LinkedList <IElement> LeftResult = new LinkedList <IElement>();

                        foreach (IElement LeftChild in LeftChildren)
                        {
                            LinkedList <IElement> RightResult = new LinkedList <IElement>();

                            foreach (IElement RightChild in RightChildren)
                            {
                                RightResult.AddLast(EvaluateSubtraction(LeftChild, RightChild, Node));
                            }

                            LeftResult.AddLast(Right.Encapsulate(RightResult, Node));
                        }

                        return(Left.Encapsulate(LeftResult, Node));
                    }
                }
            }
        }
        /// <summary>
        /// ������ɾ������Ԫ��
        /// </summary>
        /// <params name="groupElement"></params>
        void RemoveElementFromGroupElement(IGroupElement groupElement)
        {
            if (groupElement == null || groupElement.ElementCount == 0)
                return;
            try
            {
                IGraphicsContainer g = m_hookHelper.ActiveView.GraphicsContainer;
                for (int index = 0; index < groupElement.ElementCount; index++)
                {
                    IElement tmp_Ele = groupElement.get_Element(index);
                    if (tmp_Ele is IGroupElement)
                        RemoveElementFromGroupElement(tmp_Ele as IGroupElement);
                    else
                    {
                        try
                        {
                            groupElement.DeleteElement(tmp_Ele);
                        }
                        catch
                        {

                        }
                        finally
                        {
                            tmp_Ele = null;
                        }
                    }
                }
                //groupElement.ClearElements();
            }
            catch
            { }
            finally
            {
                //ˢ��
                IEnvelope pEnvBounds = null;

                //��ȡ��һ�ι켣�ߵķ�Χ,�Ա�ȷ��ˢ�·�Χ
                try
                {
                    if (m_TraceLine != null)
                    {
                        m_TraceLine.QueryEnvelope(pEnvBounds);
                        pEnvBounds.Expand(4, 4, true); //���ο�����������4��(����2������),Ŀ����Ϊ�˱�֤�г����ˢ������
                    }
                    else
                        pEnvBounds = m_hookHelper.ActiveView.Extent;
                }
                catch
                {
                    pEnvBounds = m_hookHelper.ActiveView.Extent;
                }
                m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, pEnvBounds);
            }
        }
        /// <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();
            }
        }
Example #33
0
        /// <summary>
        /// ��ʼ������
        /// </summary>
        void Init()
        {
            //��ʼ��
            m_Elements = new GroupElementClass();
            m_TraceElement = new GroupElementClass();
            m_VertexElement = new GroupElementClass();
            m_LabelElement = new GroupElementClass();

            //��ʼ��,����ӵ�GraphicsContainer
            IGraphicsContainer graphicsContainer = m_hookHelper.ActiveView as IGraphicsContainer;
            graphicsContainer.AddElement(m_Elements as IElement, 0);
            graphicsContainer.AddElement(m_TraceElement as IElement, 0);
            graphicsContainer.AddElement(m_VertexElement as IElement, 0);
            graphicsContainer.AddElement(m_LabelElement as IElement, 0);

            //��ӵ�m_Elements��
            graphicsContainer.MoveElementToGroup(m_VertexElement as IElement, m_Elements);
            graphicsContainer.MoveElementToGroup(m_LabelElement as IElement, m_Elements);
            graphicsContainer.MoveElementToGroup(m_TraceElement as IElement, m_Elements);
        }