Ejemplo n.º 1
0
        private void method_4(IGraphicsContainer igraphicsContainer_0, IEnvelope ienvelope_0)
        {
            IGroupElement2           element          = null;
            IGraphicsContainerSelect select           = igraphicsContainer_0 as IGraphicsContainerSelect;
            IEnumElement             selectedElements = select.SelectedElements;

            selectedElements.Reset();
            IElement element3 = selectedElements.Next();

            element = new GroupElementClass();
            (element as IElement).Geometry = ienvelope_0;
            while (element3 != null)
            {
                element.AddElement(element3);
                element.Refresh();
                element3 = selectedElements.Next();
            }
            igraphicsContainer_0.AddElement(element as IElement, -1);
            (element as IElement).QueryBounds((igraphicsContainer_0 as IActiveView).ScreenDisplay, ienvelope_0);
            selectedElements.Reset();
            for (element3 = selectedElements.Next(); element3 != null; element3 = selectedElements.Next())
            {
                igraphicsContainer_0.DeleteElement(element3);
            }
            select.SelectElement(element as IElement);
        }
Ejemplo n.º 2
0
        private void GroupElement(IGraphicsContainer pGC, IEnvelope pEnvelop)
        {
            IGroupElement2           groupElementClass       = null;
            IGraphicsContainerSelect graphicsContainerSelect = pGC as IGraphicsContainerSelect;
            IEnumElement             selectedElements        = graphicsContainerSelect.SelectedElements;

            selectedElements.Reset();
            IElement i = selectedElements.Next();

            if (groupElementClass == null)
            {
                groupElementClass = new GroupElement() as IGroupElement2;
                (groupElementClass as IElement).Geometry = pEnvelop;
                while (i != null)
                {
                    groupElementClass.AddElement(i);
                    groupElementClass.Refresh();
                    i = selectedElements.Next();
                }
            }
            pGC.AddElement(groupElementClass as IElement, -1);
            (groupElementClass as IElement).QueryBounds((pGC as IActiveView).ScreenDisplay, pEnvelop);
            selectedElements.Reset();
            for (i = selectedElements.Next(); i != null; i = selectedElements.Next())
            {
                pGC.DeleteElement(i);
            }
            graphicsContainerSelect.SelectElement(groupElementClass as IElement);
        }
Ejemplo n.º 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, "", "", "");
     }
 }
Ejemplo n.º 4
0
        public override void OnClick()
        {
            IGraphicsContainer       graphicsContainer       = this._context.ActiveView.GraphicsContainer;
            IGraphicsContainerSelect graphicsContainerSelect = graphicsContainer as IGraphicsContainerSelect;
            IEnumElement             selectedElements        = graphicsContainerSelect.SelectedElements;
            MapTemplateGroupElement  mapTemplateGroupElement = new MapTemplateGroupElement(MapTemplate.CurrentMapTemplate);

            mapTemplateGroupElement.Create(selectedElements);
            mapTemplateGroupElement.Save();
            List <IElement> list = new List <IElement>();

            selectedElements.Reset();
            for (IElement element = selectedElements.Next(); element != null; element = selectedElements.Next())
            {
                list.Add(element);
            }
            foreach (IElement current in list)
            {
                graphicsContainer.DeleteElement(current);
            }
            IGraphicsContainer graphicsContainer2 = this._context.ActiveView.GraphicsContainer;
            IElement           element2           = mapTemplateGroupElement.GetElement(this._context.ActiveView as IPageLayout);

            graphicsContainer2.AddElement(element2, -1);
            this._context.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, element2, null);
        }
Ejemplo n.º 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);
         }
     }
 }
Ejemplo n.º 6
0
        private void method_0()
        {
            IGraphicsContainer       graphicsContainer       = this.iactiveView_0.GraphicsContainer;
            IGraphicsContainerSelect graphicsContainerSelect = graphicsContainer as IGraphicsContainerSelect;

            graphicsContainerSelect.UnselectAllElements();
            this.ienumElement_0.Reset();
            IElement element = this.ienumElement_0.Next();

            this.ilist_0.Clear();
            while (element != null)
            {
                if ((!(element is IGraphicsComposite) ? false : !(element is IMapFrame)))
                {
                    IEnumElement graphics =
                        (element as IGraphicsComposite).Graphics[this.iactiveView_0.ScreenDisplay, null];
                    graphics.Reset();
                    for (IElement i = graphics.Next(); i != null; i = graphics.Next())
                    {
                        graphicsContainer.AddElement(i, -1);
                        graphicsContainerSelect.SelectElement(element);
                        this.ilist_0.Add(i);
                    }
                }
                element = this.ienumElement_0.Next();
            }
            foreach (IElement list0 in this.list_0)
            {
                graphicsContainer.DeleteElement(list0);
            }
        }
Ejemplo n.º 7
0
        protected override void OnMouseDown(MouseEventArgs arg)
        {
            IMxDocument pmxdoc = ArcMap.Application.Document as IMxDocument;

            IPoint pPoint = pmxdoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y);

            IGraphicsContainer pgc       = pmxdoc.ActiveView.GraphicsContainer;
            IEnumElement       eElements = pgc.LocateElements(pPoint, 5);

            if (eElements == null)
            {
                return;
            }

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

            while (pElement != null)
            {
                IElementProperties pElementProps = pElement as IElementProperties;

                MessageBox.Show(pElementProps.Name);

                pElement = eElements.Next();
            }
        }
Ejemplo n.º 8
0
 private IEnvelope method_3(IGraphicsContainerSelect igraphicsContainerSelect_0)
 {
     try
     {
         IEnumElement selectedElements = igraphicsContainerSelect_0.SelectedElements;
         selectedElements.Reset();
         IEnvelope envelope   = null;
         IEnvelope inEnvelope = null;
         for (IElement element2 = selectedElements.Next(); element2 != null; element2 = selectedElements.Next())
         {
             if (envelope == null)
             {
                 envelope = element2.Geometry.Envelope;
             }
             else
             {
                 inEnvelope = element2.Geometry.Envelope;
                 envelope.Union(inEnvelope);
             }
         }
         if ((envelope != null) && ((envelope.Width == 0.0) || (envelope.Height == 0.0)))
         {
             envelope.Expand(0.001, 0.001, false);
             return(envelope);
         }
     }
     catch (Exception)
     {
     }
     return(null);
 }
Ejemplo n.º 9
0
        private void method_0()
        {
            this.ienumElement_0.Reset();
            IElement                 element                 = this.ienumElement_0.Next();
            IGraphicsContainer       graphicsContainer       = this.iactiveView_0.GraphicsContainer;
            IGraphicsContainerSelect graphicsContainerSelect = graphicsContainer as IGraphicsContainerSelect;

            graphicsContainerSelect.UnselectAllElements();
            graphicsContainer.DeleteElement(element);
            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())
                    {
                        (element as IElementProperties2).AutoTransform = true;
                        graphicsContainer.AddElement(i, -1);
                        graphicsContainerSelect.SelectElement(i);
                    }
                }
                element = this.ienumElement_0.Next();
            }
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
0
        private void method_0()
        {
            IElement element2;
            IGraphicsContainerSelect select = this.ipageLayout_0 as IGraphicsContainerSelect;

            if (select.ElementSelectionCount > 0)
            {
                this.rdoPlaceSelectElement.Enabled = true;
                this.rdoPlaceSelectElement.Checked = true;
                this.rdoPlaceAllElement.Checked    = false;
                this.rdoPlacePageMargine.Checked   = false;
                IEnumElement selectedElements = select.SelectedElements;
                selectedElements.Reset();
                element2 = selectedElements.Next();
                if ((select.ElementSelectionCount == 1) && (element2 is IFrameElement))
                {
                    this.chkNewFrameElement.Checked = false;
                    this.chkNewFrameElement.Enabled = true;
                    this.chkGroup.Checked           = false;
                    this.chkGroup.Enabled           = false;
                    this.iframeElement_0            = element2 as IFrameElement;
                    this.method_1(element2 as IFrameElement);
                }
                else
                {
                    this.chkNewFrameElement.Checked = true;
                    this.chkNewFrameElement.Enabled = false;
                    this.chkGroup.Checked           = false;
                    this.chkGroup.Enabled           = true;
                }
            }
            else
            {
                this.rdoPlaceSelectElement.Enabled = false;
                this.rdoPlaceSelectElement.Checked = false;
                this.rdoPlaceAllElement.Checked    = true;
                this.rdoPlacePageMargine.Checked   = false;
                IGraphicsContainer container = this.ipageLayout_0 as IGraphicsContainer;
                container.Reset();
                element2 = container.Next();
                if (!((container.Next() == null) && (element2 is IFrameElement)))
                {
                    this.chkNewFrameElement.Checked = true;
                    this.chkNewFrameElement.Enabled = false;
                    this.chkGroup.Checked           = false;
                    this.chkGroup.Enabled           = true;
                }
                else
                {
                    this.chkNewFrameElement.Checked = false;
                    this.chkNewFrameElement.Enabled = true;
                    this.chkGroup.Checked           = false;
                    this.chkGroup.Enabled           = false;
                    this.iframeElement_0            = element2 as IFrameElement;
                    this.method_1(element2 as IFrameElement);
                }
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            try
            {
                m_pAV = m_pHookHelper.ActiveView;
                IViewManager pViewManager = (IViewManager)m_pAV;
                IEnumElement pEnumElement = (IEnumElement)pViewManager.ElementSelection;
                pEnumElement.Reset();
                IElement pElement = pEnumElement.Next();
                if (pElement == null)
                {
                    return;
                }
                int i = 0;
                while (pElement != null)
                {
                    i++;
                    pElement = pEnumElement.Next();
                    if (i > 1)
                    {
                        return;
                    }
                }

                pEnumElement.Reset();
                pElement = pEnumElement.Next();
                if (pElement is IMapSurroundFrame)
                {
                    IMapSurroundFrame pMapSFrame = (IMapSurroundFrame)pElement;
                    if (pMapSFrame.MapSurround is ILegend)
                    {
                        frmAddLegend vFrmLegend = new frmAddLegend(false);
                        vFrmLegend.SetMapSurroundFrame(pMapSFrame);
                        return;
                    }
                }
                frmElementProperty frm = new frmElementProperty(2);
                frm.StartEditElement(m_pAV, ref pElement);
                frm.ShowDialog();
                frm.Dispose();
            }
            catch { }
        }
Ejemplo n.º 13
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     if (elementEnums != null)
     {
         elementEnums.Reset();
     }
     envelope          = null;
     rectangleFeedback = null;
     if (listElements != null)
     {
         listElements.Clear();
     }
     listElements = null;
 }
Ejemplo n.º 14
0
        public static IElement getElement(AxPageLayoutControl axPageLayoutControl, IPoint pPoint)
        {
            IPageLayout        pageLayout         = axPageLayoutControl.PageLayout;
            IGraphicsContainer pGraphicsContainer = pageLayout as IGraphicsContainer;
            IEnumElement       pEnumElement       = pGraphicsContainer.LocateElements(pPoint, 0);

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

            while (pElement != null && (pElement is IMapFrame))
            {
                pElement = pEnumElement.Next();
            }
            return(pElement);
        }
Ejemplo n.º 15
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);
     }
 }
Ejemplo n.º 16
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)
            {
            }
        }
Ejemplo n.º 17
0
 public bool HitTestElement(IActiveView pActiveView, long x, long y, bool bMapUnit)
 {
     try
     {
         if (pActiveView != null)
         {
             IPoint point = null;
             if (bMapUnit)
             {
                 point = new PointClass {
                     X = x,
                     Y = y
                 };
             }
             else
             {
                 point = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint((int)x, (int)y);
             }
             double dPixelUnits = 3.0;
             dPixelUnits = GISFunFactory.UnitFun.ConvertPixelsToMapUnits(pActiveView, dPixelUnits, true);
             IEnumElement element = null;
             element = (pActiveView as IGraphicsContainer).LocateElements(point, dPixelUnits);
             if (element == null)
             {
                 return(false);
             }
             IElement element2 = null;
             element.Reset();
             for (element2 = element.Next(); element2 != null; element2 = element.Next())
             {
                 if (!element2.Locked)
                 {
                     return(true);
                 }
             }
         }
         return(false);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.ElementFun", "HitTestElement", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(false);
     }
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add CmdDelectSelElement.OnClick implementation

            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++)
            {
                pGraphicsContainer.DeleteElement(pElement);
                pElement = pEnumElement.Next();
                m_hookHelper.ActiveView.Refresh();
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 根据点击位置和需要的element类型,取得在该位置的给类型的element
        /// </summary>
        /// <param name="pPoint"></param>
        /// <param name="geometryType"></param>
        /// <returns></returns>
        private IElement getElement(IPoint pPoint, esriGeometryType geometryType)
        {
            IEnumElement pEnumElement = this.pGraphicContainer.LocateElements(pPoint, this.axMapControl1.ActiveView.Extent.Width / 100);

            if (pEnumElement != null)
            {
                pEnumElement.Reset();
                IElement pElement;
                for (pElement = pEnumElement.Next(); pElement != null; pElement = pEnumElement.Next())
                {
                    if (pElement.Geometry.GeometryType == geometryType)
                    {
                        this.hitElement = pElement;
                        return(pElement);
                    }
                }
                return(null);
            }
            return(null);
        }
Ejemplo n.º 20
0
        public override void OnClick()
        {
            ISelectionEnvironment selectionEnvironmentClass = _plugin.QuerySettings.SelectionEnvironment;
            IMap         pMap             = _context.MapControl.Map;
            IEnumElement selectedElements = (pMap as IGraphicsContainerSelect).SelectedElements;

            selectedElements.Reset();
            IElement i = selectedElements.Next();

            if (i != null)
            {
                (pMap as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                try
                {
                    pMap.SelectByShape(i.Geometry, selectionEnvironmentClass, false);
                }
                catch
                {
                }
                esriSelectionResultEnum combinationMethod = selectionEnvironmentClass.CombinationMethod;
                selectionEnvironmentClass.CombinationMethod = esriSelectionResultEnum.esriSelectionResultAdd;
                for (i = selectedElements.Next(); i != null; i = selectedElements.Next())
                {
                    try
                    {
                        pMap.SelectByShape(i.Geometry, selectionEnvironmentClass, false);
                    }
                    catch
                    {
                    }
                }
                (pMap as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                selectionEnvironmentClass.CombinationMethod = combinationMethod;
            }
            else
            {
                MessageService.Current.Info("请先选择准备用于选择要素的图形!");
            }
        }
Ejemplo n.º 21
0
 private void rdoPlaceSelectElement_CheckedChanged(object sender, EventArgs e)
 {
     if (this.bool_0)
     {
         IGraphicsContainerSelect select           = this.ipageLayout_0 as IGraphicsContainerSelect;
         IEnumElement             selectedElements = select.SelectedElements;
         selectedElements.Reset();
         IElement element2 = selectedElements.Next();
         if ((select.ElementSelectionCount == 1) && (element2 is IFrameElement))
         {
             this.chkNewFrameElement.Enabled = true;
             this.chkGroup.Enabled           = this.chkNewFrameElement.Checked;
             this.chkGroup.Checked           = false;
         }
         else
         {
             this.chkNewFrameElement.Checked = true;
             this.chkNewFrameElement.Enabled = false;
             this.chkGroup.Enabled           = true;
         }
     }
 }
Ejemplo n.º 22
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);
        }
Ejemplo n.º 23
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);
        }
Ejemplo n.º 24
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);
     }
 }
Ejemplo n.º 25
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, "", "", "");
     }
 }
Ejemplo n.º 26
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, "", "", "");
     }
 }
Ejemplo n.º 27
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();
            }
        }
Ejemplo n.º 28
0
        public static int get_Dimensionality(IEnumElement theElements, out bool multipart)
        {
            int theReturn = -1;
            multipart = false;

            if (theElements != null)
            {
                theElements.Reset();
                IElement theElement = theElements.Next();
                while (theElement != null)
                {
                    int theDim = -1;
                    if (theElement is IGroupElement)
                    {
                        theDim = get_Dimensionality(((IGroupElement)theElement).Elements, out multipart);
                    }
                    else if (theElement is IFillShapeElement)
                    {
                        if (theElement is ICircleElement
                            || theElement is IPolygonElement
                            || theElement is IRectangleElement
                            || theElement is IEllipseElement)
                            theDim = 2;
                    }
                    else if (theElement is ILineElement)
                    {
                        theDim = 1;
                    }
                    else if (theElement is IMarkerElement)
                    {
                        theDim = 0;
                    }

                    if (theReturn == -1)
                        theReturn = theDim;
                    else if (theReturn != theDim)
                        theReturn = -1;
                    else
                        multipart = true;

                    if (theReturn == -1)
                        break;

                    theElement = theElements.Next();
                }
            }
            return theReturn;
        }
Ejemplo n.º 29
0
 public bool HitTestSelectionElement(IActiveView pActiveView, long x, long y, bool bMapUnit)
 {
     try
     {
         if (pActiveView != null)
         {
             IGraphicsContainerSelect select = pActiveView as IGraphicsContainerSelect;
             if (select.ElementSelectionCount <= 0)
             {
                 return(false);
             }
             IPoint point = null;
             if (bMapUnit)
             {
                 point = new PointClass {
                     X = x,
                     Y = y
                 };
             }
             else
             {
                 point = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint((int)x, (int)y);
             }
             IEnvelope           bounds           = new EnvelopeClass();
             IBoundsProperties   properties       = null;
             IGeometry           other            = null;
             IRelationalOperator @operator        = point as IRelationalOperator;
             IEnumElement        selectedElements = null;
             selectedElements = select.SelectedElements;
             if (selectedElements == null)
             {
                 return(false);
             }
             IElement element2 = null;
             selectedElements.Reset();
             for (element2 = selectedElements.Next(); element2 != null; element2 = selectedElements.Next())
             {
                 if (!element2.Locked)
                 {
                     properties = element2 as IBoundsProperties;
                     if (properties.FixedSize)
                     {
                         element2.QueryBounds(pActiveView.ScreenDisplay, bounds);
                     }
                     else
                     {
                         bounds = element2.Geometry.Envelope;
                     }
                     other = bounds;
                     if (@operator.Within(other))
                     {
                         return(true);
                     }
                 }
             }
         }
         return(false);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.ElementFun", "HitTestSelectionElement", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(false);
     }
 }
Ejemplo n.º 30
0
        public static IGeometry get_GraphicShape(IEnumElement theElements, int a_Dimensionality, bool multipart)
        {
            IGeometry theReturn = null;
            IGeometryCollection theGeomColl = null;
            object missing = Type.Missing;

            if (theElements != null)
            {
                theElements.Reset();
                IElement theElement = theElements.Next();
                while (theElement != null)
                {
                    if (theGeomColl == null)
                        theGeomColl = new GeometryBagClass();

                    IGeometry theShape = null;
                    if (theElement is IGroupElement)
                    {
                        theShape = get_GraphicShape(((IGroupElement)theElement).Elements, a_Dimensionality, multipart);
                    }
                    else if (theElement is ICircleElement
                        || theElement is IPolygonElement
                        || theElement is IRectangleElement
                        || theElement is IEllipseElement
                        || theElement is ILineElement
                        || theElement is IMarkerElement)
                        theShape = theElement.Geometry;

                    if (theShape != null)
                        theGeomColl.AddGeometry(theShape, ref missing, ref missing);

                    theElement = theElements.Next();
                }
            }

            if (theGeomColl != null && theGeomColl.GeometryCount > 0)
            {
                ITopologicalOperator theTopoOp = null;

                switch (a_Dimensionality)
                {
                    case 0:
                        if (multipart)
                        {
                            theTopoOp = new MultipointClass();
                            theTopoOp.ConstructUnion((IEnumGeometry)theGeomColl);
                        }
                        else
                            theTopoOp = theGeomColl.get_Geometry(0) as ITopologicalOperator;
                        break;
                    case 1:
                        theTopoOp = new PolylineClass();
                        theTopoOp.ConstructUnion((IEnumGeometry)theGeomColl);
                        break;
                    case 2:
                        theTopoOp = new PolygonClass();
                        theTopoOp.ConstructUnion((IEnumGeometry)theGeomColl);
                        break;
                }

                theReturn = theTopoOp as IGeometry;
            }
            return theReturn;
        }
Ejemplo n.º 31
0
        private static IGeometry get_GraphicShape(IEnumElement theElements, int a_Dimensionality, bool multipart, ref IElementCollection elemCollection)
        {
            IGeometry theReturn = null;
            IGeometryCollection theGeomColl = null;
            object missing = Type.Missing;

            try
            {
                elemCollection.Clear();

                if (theElements != null)
                {
                    theElements.Reset();
                    IElement theElement = theElements.Next();
                    while (theElement != null)
                    {
                        if (theGeomColl == null)
                            theGeomColl = new GeometryBagClass();

                        IGeometry theShape = null;
                        if (theElement is IGroupElement)
                        {
                            theShape = get_GraphicShape(((IGroupElement)theElement).Elements, a_Dimensionality, multipart,ref elemCollection);
                        }
                        else if (theElement is ICircleElement
                            || theElement is IPolygonElement
                            || theElement is IRectangleElement
                            || theElement is IEllipseElement
                            || theElement is ILineElement
                            || theElement is IMarkerElement)
                            theShape = theElement.Geometry;

                        if (theShape != null)
                            theGeomColl.AddGeometry(theShape, ref missing, ref missing);

                        elemCollection.Add(theElement,-1);

                        theElement = theElements.Next();
                    }
                }

                if (theGeomColl != null && theGeomColl.GeometryCount > 0)
                {
                    ITopologicalOperator theTopoOp = null;

                    switch (a_Dimensionality)
                    {
                        case 0:
                            if (multipart)
                            {
                                theTopoOp = new MultipointClass();
                                theTopoOp.ConstructUnion((IEnumGeometry)theGeomColl);
                            }
                            else
                                theTopoOp = theGeomColl.get_Geometry(0) as ITopologicalOperator;
                            break;
                        case 1:
                            theTopoOp = new PolylineClass();
                            theTopoOp.ConstructUnion((IEnumGeometry)theGeomColl);
                            break;
                        case 2:
                            theTopoOp = new PolygonClass();
                            theTopoOp.ConstructUnion((IEnumGeometry)theGeomColl);
                            break;
                    }

                    theReturn = theTopoOp as IGeometry;
                }
            }
            catch(Exception ex)
            {
                util.Logger.Write(" Descrip  : Finding elements with a specific dimensionality. " +
                    "\n Message  : " + ex.Message +
                    "\n StackTrc : " + ex.StackTrace,util.Logger.LogLevel.Debug);

            }
            return theReturn;
        }
Ejemplo n.º 32
0
        //回退操作
        private void  Undo()
        {
            if (m_pUndoArray.Count == 0)
            {
                return;
            }

            if (m_pUndoArray.Count > 1)
            {
                m_pEnvelope = CommonFunction.GetMinEnvelopeOfTheArray(m_pUndoArray);
            }
            else if (m_pUndoArray.Count == 1)
            {
                IPoint pTempPoint = new PointClass();
                pTempPoint.X = (m_pUndoArray.get_Element(0) as Point).X;
                pTempPoint.Y = (m_pUndoArray.get_Element(0) as Point).Y;

                m_pEnvelope.Width  = Math.Abs(m_pPoint.X - pTempPoint.X);
                m_pEnvelope.Height = Math.Abs(m_pPoint.Y - pTempPoint.Y);

                pTempPoint.X = (pTempPoint.X + m_pPoint.X) / 2;
                pTempPoint.Y = (pTempPoint.Y + m_pPoint.Y) / 2;

                m_pEnvelope.CenterAt(pTempPoint);
            }
            if (m_pEnvelope != null && !m_pEnvelope.IsEmpty)
            {
                m_pEnvelope.Expand(10, 10, false);
            }

            IPoint pPoint = new PointClass();

            pPoint = (IPoint)m_pUndoArray.get_Element(m_pUndoArray.Count - 1);
            IEnvelope enve = new EnvelopeClass();

            enve = CommonFunction.NewRect(pPoint, m_dblTolerance);

            IEnumElement pEnumElement = m_MapControl.ActiveView.GraphicsContainer.LocateElementsByEnvelope(enve);

            if (pEnumElement != null)
            {
                pEnumElement.Reset();
                IElement pElement = pEnumElement.Next();

                while (pElement != null)
                {
                    m_MapControl.ActiveView.GraphicsContainer.DeleteElement(pElement);
                    pElement = pEnumElement.Next();
                }
            }
            m_MapControl.ActiveView.Refresh();

            m_pUndoArray.Remove(m_pUndoArray.Count - 1);          //删除数组中最后一个点

            //屏幕刷新
            //m_pActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground,null,null);

            m_pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, m_pEnvelope);            //视图刷新

            m_pActiveView.ScreenDisplay.UpdateWindow();

            //开始作复位工作
            if (m_pUndoArray.Count != 0)
            {
                UpdataBezierCurveFeed(m_MapControl, ref m_pUndoArray);
                m_pBezierCurveFeed.MoveTo(m_pAnchorPoint);
            }
            else
            {
                Reset();                 //复位
            }
        }
Ejemplo n.º 33
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();
            }
        }
Ejemplo n.º 34
0
        private static int get_Dimensionality(IEnumElement theElements, out bool multipart)
        {
            int theReturn = -1;
            multipart = false;

            try
            {

                if (theElements != null)
                {
                    theElements.Reset();
                    IElement theElement = theElements.Next();
                    while (theElement != null)
                    {
                        int theDim = -1;
                        if (theElement is IGroupElement)
                        {
                            theDim = get_Dimensionality(((IGroupElement)theElement).Elements, out multipart);
                        }
                        else if (theElement is IFillShapeElement)
                        {
                            if (theElement is ICircleElement
                                || theElement is IPolygonElement
                                || theElement is IRectangleElement
                                || theElement is IEllipseElement)
                                theDim = 2;
                        }
                        else if (theElement is ILineElement)
                        {
                            theDim = 1;
                        }
                        else if (theElement is IMarkerElement)
                        {
                            theDim = 0;
                        }

                        if (theReturn == -1)
                            theReturn = theDim;
                        else if (theReturn != theDim)
                            theReturn = -1;
                        else
                            multipart = true;

                        if (theReturn == -1)
                            break;

                        theElement = theElements.Next();
                    }
                }
            }
            catch(Exception ex)
            {
                util.Logger.Write(" Descrip  : Determining the dimensionality of graphic elements. " +
                                "\n Message  : " + ex.Message +
                                "\n StackTrc : " + ex.StackTrace,util.Logger.LogLevel.Debug);
            }
            return theReturn;
        }