Пример #1
0
        /// <summary>
        /// Gets all map groups in the map including the nested groups.
        /// </summary>
        /// <returns>the list of the groups</returns>
        public static List <IMapGroup> GetAllGroups(this IMapFrame mapFrame)
        {
            var groupList = new List <IMapGroup>();

            GetNestedGroups(mapFrame, groupList);
            return(groupList);
        }
Пример #2
0
        /// <summary>
        /// 文字比例尺
        /// </summary>
        /// <returns></returns>
        public bool AddTxtSacleBar()
        {
            IStyleSelector pStyleSelector = new ScaleTextSelectorClass();
            bool           m_bOK          = pStyleSelector.DoModal(0);

            if (m_bOK == true)
            {
                IScaleText pScaleText = pStyleSelector.GetStyle(0) as IScaleText;

                IEnvelope envelope = new EnvelopeClass();
                envelope.PutCoords(0.2, 0.2, 5, 1);
                ESRI.ArcGIS.esriSystem.IUID uid = new ESRI.ArcGIS.esriSystem.UIDClass();
                uid.Value = "esriCarto.Scaletext";
                IMap pMap = mainPage.ActiveView.FocusMap;
                IGraphicsContainer graphicsContainer = mainPage.ActiveView as IGraphicsContainer;
                IActiveView        activeView        = mainPage.ActiveView as IActiveView;
                IFrameElement      frameElement      = graphicsContainer.FindFrame(pMap);
                IMapFrame          mapFrame          = frameElement as IMapFrame;
                IMapSurroundFrame  mapSurroundFrame  = mapFrame.CreateSurroundFrame(uid as ESRI.ArcGIS.esriSystem.UID, null);
                IMapSurround       mapsurround       = pScaleText as IMapSurround;
                mapSurroundFrame.MapSurround = mapsurround;
                IElement element = mapSurroundFrame as IElement;
                element.Geometry = envelope;
                element.Activate(activeView.ScreenDisplay);
                graphicsContainer.AddElement(element, 0);
                IMapSurround mapSurround = mapSurroundFrame.MapSurround;
            }
            return(true);
        }
Пример #3
0
 public Map(Size size)
 {
     Size     = size;
     Layers   = new List <ILayer>();
     MapFrame = new MapFrame(Util.Convert(size));
     ListenEvents();
 }
Пример #4
0
        void addNorthArrow(IPageLayout pPageLayout, IEnvelope pEnv, IActiveView pActiveView)
        {
            IMap pMap = pActiveView.FocusMap;
            IGraphicsContainer pGraphicsContainer = pPageLayout as IGraphicsContainer;
            IMapFrame          pMapFrame          = pGraphicsContainer.FindFrame(pMap) as IMapFrame;

            if (pStyleGalleryItem == null)
            {
                return;
            }
            IMapSurroundFrame pMapSurroundFrame = new MapSurroundFrameClass();

            pMapSurroundFrame.MapFrame = pMapFrame;
            INorthArrow pNorthArrow = new MarkerNorthArrowClass();

            pNorthArrow      = pStyleGalleryItem.Item as INorthArrow;
            pNorthArrow.Size = pEnv.Width * 50;
            pMapSurroundFrame.MapSurround = (IMapSurround)pNorthArrow;                 //根据用户的选取,获取相应的MapSurround
            IElement pElement = axPageLayoutControl1.FindElementByName("NorthArrows"); //获取PageLayout中的指北针元素

            if (pElement != null)
            {
                pGraphicsContainer.DeleteElement(pElement);  //如果存在指北针,删除已经存在的指北针
            }
            IElementProperties pElePro = null;

            pElement          = (IElement)pMapSurroundFrame;
            pElement.Geometry = (IGeometry)pEnv;
            pElePro           = pElement as IElementProperties;
            pElePro.Name      = "NorthArrows";
            pGraphicsContainer.AddElement(pElement, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Пример #5
0
 public void ActivatePageLayout()
 {
     try
     {
         this.axPageLayoutControl_0.Visible = true;
         this.axMapControl_0.Visible        = false;
         if (this.imapControl3_0.CurrentTool != null)
         {
             this.itool_0 = this.imapControl3_0.CurrentTool;
         }
         IMapFrame focusMapFrame = this.GetFocusMapFrame(this.ipageLayoutControl2_0.PageLayout);
         (focusMapFrame.Map as IMapClipOptions).ClipType = esriMapClipType.esriMapClipNone;
         if (focusMapFrame.Map is IMapAutoExtentOptions)
         {
             (focusMapFrame.Map as IMapAutoExtentOptions).AutoExtentType = esriExtentTypeEnum.esriExtentDefault;
         }
         (focusMapFrame.Map as IActiveView).Extent = this.axMapControl_0.ActiveView.Extent;
         if (this.itool_1 != null)
         {
             this.ipageLayoutControl2_0.CurrentTool = this.itool_1;
         }
         this.bool_0 = false;
         if (this.onActiveHookChangedHandler_0 != null)
         {
             this.onActiveHookChangedHandler_0(this);
         }
     }
     catch (Exception exception)
     {
         throw new Exception(string.Format("ControlsSynchronizer::ActivatePageLayout:\r\n{0}", exception.Message));
     }
 }
Пример #6
0
        public void AddMapGrid()
        {
            m_styleSelector = new MapGridSelectorClass();             //Create a style selector and grab holf of the IMapGridSelector interface

            m_Ok = m_styleSelector.DoModal(m_pagelayoutControl.hWnd); //Display the style selector to the user

            IGraphicsContainer graphicsContainer = m_pagelayoutControl.GraphicsContainer;
            //Get the MapFrame
            IMapFrame mapFrame = (IMapFrame)graphicsContainer.FindFrame(m_pagelayoutControl.ActiveView.FocusMap);

            if (mapFrame == null)
            {
                return;
            }

            if (m_Ok == true)
            {
                IMapGrid m_mapGrid;
                m_mapGrid = (IMapGrid )m_styleSelector.GetStyle(0);//获得所选的MapGrid的类型;

                IMapGrids m_mapGrids = mapFrame as IMapGrids;

                m_mapGrids.ClearMapGrids();//删除原有的地图格网

                if (m_mapGrid != null)
                {
                    m_mapGrids.AddMapGrid(m_mapGrid);                                                          //添加地图格网到地图上
                }
                m_pagelayoutControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); //刷新
            }
        }
Пример #7
0
        public static IMapFrame FindFocusMapFrame(IPageLayout ipageLayout_0)
        {
            IActiveView        view      = ipageLayout_0 as IActiveView;
            IMap               focusMap  = view.FocusMap;
            IGraphicsContainer container = ipageLayout_0 as IGraphicsContainer;

            container.Reset();
            for (IElement element = container.Next(); element != null; element = container.Next())
            {
                if (element is IMapFrame)
                {
                    if (focusMap == (element as IMapFrame).Map)
                    {
                        return(element as IMapFrame);
                    }
                }
                else if (element is IGroupElement)
                {
                    IMapFrame frame2 = FindFocusMapFrame(element as IGroupElement, focusMap);
                    if (frame2 != null)
                    {
                        return(frame2);
                    }
                }
            }
            return(null);
        }
 public override void OnMouseDown(int Button, int Shift, int X, int Y)
 {
     // TODO:  Add AddScaleBar.OnMouseDown implementation
     if (Button == 1)
     {
         IEnvelope pEnv;
         pEnv = pPageLayoutControl.TrackRectangle();
         GetSymbol symbolForm = new GetSymbol(esriSymbologyStyleClass.
                                              esriStyleClassScaleBars);
         symbolForm.Text = "Choose Scale Bar";
         IStyleGalleryItem styleGalleryItem = symbolForm.GetItem
                                                  (esriSymbologyStyleClass.esriStyleClassNorthArrows);
         symbolForm.Dispose();
         if (styleGalleryItem == null)
         {
             return;
         }
         IMapFrame mapFrame = (IMapFrame)m_hookHelper.ActiveView.GraphicsContainer.
                              FindFrame(m_hookHelper.ActiveView.FocusMap);
         IMapSurroundFrame mapSurroundFrame = new MapSurroundFrameClass();
         mapSurroundFrame.MapFrame    = mapFrame;
         mapSurroundFrame.MapSurround = (IMapSurround)styleGalleryItem.Item;
         IElement element = (IElement)mapSurroundFrame;
         element.Geometry = pEnv;
         m_hookHelper.ActiveView.GraphicsContainer.AddElement
             ((IElement)mapSurroundFrame, 0);
         m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics,
                                                mapSurroundFrame, null);
     }
 }
Пример #9
0
        private void Btn_AddLegend_Click(object sender, EventArgs e)
        {
            IGraphicsContainer pGraphicsContainer = Ctrl_PageLayout.ActiveView.GraphicsContainer;
            IMapFrame          pMapFrame          = (IMapFrame)pGraphicsContainer.FindFrame(Ctrl_PageLayout.ActiveView.FocusMap);

            if (pMapFrame == null)
            {
                return;
            }
            UID uid = new UIDClass
            {
                Value = "esriCarto.Legend"
            };
            IMapSurroundFrame pMapSurroundFrame = pMapFrame.CreateSurroundFrame(uid, null);

            if (pMapSurroundFrame == null || pMapSurroundFrame.MapSurround == null)
            {
                return;
            }
            pMapSurroundFrame.MapSurround.Name = "Legend";
            ILegend pLegend = new Legend();

            pLegend       = pMapSurroundFrame.MapSurround as ILegend;
            pLegend.Title = "Legend";
            IElement pElement = (IElement)pMapSurroundFrame;

            pElement.Geometry = m_pEnvelopDrawed;
            if (m_pLegendElement != null)
            {
                Ctrl_PageLayout.ActiveView.GraphicsContainer.DeleteElement(m_pLegendElement);
            }
            Ctrl_PageLayout.ActiveView.GraphicsContainer.AddElement(pElement, 0);
            m_pLegendElement = pElement;
            Ctrl_PageLayout.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Пример #10
0
        /// <summary>
        /// 添加默认比例尺
        /// </summary>
        /// <param name="layoutControl">布局视图</param>
        /// <param name="pEnv">矩形框</param>
        /// <param name="pStyleGalleryItem">比例尺样式</param>
        public static void AddDefaultScaleBar(AxPageLayoutControl layoutControl, IEnvelope pEnv, IStyleGalleryItem pStyleGalleryItem)
        {
            if (pStyleGalleryItem == null)
            {
                return;
            }
            IGraphicsContainer pGraphicsContainer = layoutControl.PageLayout as IGraphicsContainer;

            if (pGraphicsContainer == null)
            {
                return;
            }
            IMap              pMap              = layoutControl.ActiveView.FocusMap;
            IMapFrame         pMapFrame         = pGraphicsContainer.FindFrame(pMap) as IMapFrame;
            IMapSurroundFrame pMapSurroundFrame = new MapSurroundFrameClass();

            pMapSurroundFrame.MapFrame = pMapFrame;
            //删除已经存在的比例尺
            MappingHelper.DeleteElementByName(layoutControl, "Scale Line");
            IScaleBar2 scaleBar2 = pStyleGalleryItem.Item as IScaleBar2;

            if (scaleBar2 != null)
            {
                scaleBar2.BarHeight           = pEnv.Height * 20;
                scaleBar2.Divisions           = 1;
                scaleBar2.Subdivisions        = 2;
                pMapSurroundFrame.MapSurround = scaleBar2 as IMapSurround;
            }
            IElement pElement = (IElement)pMapSurroundFrame;

            pElement.Geometry = pEnv;
            //添加元素
            MappingHelper.AddElementWithName(pGraphicsContainer, pElement, "Scale Line");
        }
Пример #11
0
        /// <summary>
        /// 添加比例尺
        /// </summary>
        /// <param name="layoutControl">布局视图</param>
        /// <param name="pEnv">矩形框</param>
        /// <param name="scaleBar">比例尺</param>
        public static void AddScaleBar(AxPageLayoutControl layoutControl, IEnvelope pEnv, IScaleBar2 scaleBar)
        {
            if (scaleBar == null)
            {
                return;
            }
            IGraphicsContainer pGraphicsContainer = layoutControl.PageLayout as IGraphicsContainer;

            if (pGraphicsContainer == null)
            {
                return;
            }
            IMap              pMap              = layoutControl.ActiveView.FocusMap;
            IMapFrame         pMapFrame         = pGraphicsContainer.FindFrame(pMap) as IMapFrame;
            IMapSurroundFrame pMapSurroundFrame = new MapSurroundFrameClass();

            pMapSurroundFrame.MapFrame = pMapFrame;
            scaleBar.BarHeight         = pEnv.Height * 10;
            //删除已经存在的比例尺
            MappingHelper.DeleteElementByName(layoutControl, "Scale Line");
            pMapSurroundFrame.MapSurround = scaleBar as IMapSurround;
            IElement pElement = (IElement)pMapSurroundFrame;

            pElement.Geometry = pEnv;
            //添加元素
            MappingHelper.AddElementWithName(pGraphicsContainer, pElement, "Scale Line");
        }
Пример #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MapDrawArgs"/> class.
        /// </summary>
        /// <param name="inGraphics">The graphics object used for drawing.</param>
        /// <param name="clipRectangle">The clip rectangle.</param>
        /// <param name="inMapFrame">The map frame.</param>
        public MapDrawArgs(Graphics inGraphics, Rectangle clipRectangle, IMapFrame inMapFrame)
        {
            _graphics    = inGraphics;
            _geoGraphics = new MapArgs(clipRectangle, inMapFrame.ViewExtents);

            _clipRectangle = clipRectangle;
        }
Пример #13
0
        /// <summary>
        /// 比例尺
        /// </summary>
        /// <param name="pActiveView"></param>
        /// <param name="pPageLayout"></param>
        /// <param name="pEnv"></param>
        public void makeScaleBar(IActiveView pActiveView, IPageLayout pPageLayout, IEnvelope pEnv)
        {
            IGraphicsContainer container = pPageLayout as IGraphicsContainer;
            // 获得MapFrame
            IFrameElement frameElement = container.FindFrame(pActiveView.FocusMap);
            IMapFrame     mapFrame     = frameElement as IMapFrame;
            //根据MapSurround的uid,创建相应的MapSurroundFrame和MapSurround
            UID uid = new UIDClass();

            uid.Value = "esriCarto.AlternatingScaleBar";
            IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uid, null);
            //设置MapSurroundFrame中比例尺的样式
            IMapSurround mapSurround    = mapSurroundFrame.MapSurround;
            IScaleBar    markerScaleBar = ((IScaleBar)mapSurround);

            markerScaleBar.LabelPosition = esriVertPosEnum.esriBelow;
            markerScaleBar.UseMapSettings();
            //QI,确定mapSurroundFrame的位置
            IElement element = mapSurroundFrame as IElement;

            element.Geometry = pEnv;
            //使用IGraphicsContainer接口添加显示
            container.AddElement(element, 0);
            pActiveView.Refresh();
        }
Пример #14
0
        private void DeleteAllElements(IActiveView pAV)
        {
            IGraphicsContainer graphicsContainer = pAV.GraphicsContainer;
            IMapFrame          mapFrame          = graphicsContainer.FindFrame(pAV.FocusMap) as IMapFrame;

            (mapFrame as IMapGrids).ClearMapGrids();
            graphicsContainer.Reset();
            IElement        element  = graphicsContainer.Next();
            List <IElement> elements = new List <IElement>();

            try
            {
                graphicsContainer.DeleteAllElements();
                graphicsContainer.Reset();
                element = graphicsContainer.Next();
                if (element != null)
                {
                    graphicsContainer.DeleteElement(element);
                }

                graphicsContainer.AddElement(mapFrame as IElement, -1);
                pAV.FocusMap = mapFrame.Map;
            }
            catch (Exception exception)
            {
            }
        }
Пример #15
0
        private void AssignLayerSymbologies(IMapFrame mapFrame)
        {
            foreach (ILayer layer in mapFrame.GetAllLayers())
            {
                IMapLineLayer lineLayer = layer as IMapLineLayer;
                if (lineLayer != null)
                {
                    ILineScheme original = lineLayer.Symbology;
                    if (original != null)
                    {
                        ILineScheme newScheme = original.Clone() as ILineScheme;
                        original.CopyProperties(newScheme);
                        original.ResumeEvents();
                    }
                }

                //to correctly draw categories:
                IMapFeatureLayer featureLayer = layer as IMapFeatureLayer;
                if (featureLayer != null)
                {
                    if (featureLayer.Symbology.NumCategories > 1)
                    {
                        featureLayer.DataSet.FillAttributes();
                        featureLayer.ApplyScheme(featureLayer.Symbology);
                    }
                }
            }
        }
Пример #16
0
        /// <summary>
        /// Gets all layers of the map frame including layers which are nested
        /// within groups. The group objects themselves are not included in this list,
        /// but all FeatureLayers, RasterLayers, ImageLayers and other layers are included.
        /// </summary>
        /// <returns>The list of the layers</returns>
        public static List <ILayer> GetAllLayers(this IMapFrame mapFrame)
        {
            List <ILayer> layerList = new List <ILayer>();

            GetNestedLayers(mapFrame, layerList);
            return(layerList);
        }
Пример #17
0
        private void method_5(IActiveView iactiveView_0)
        {
            IGraphicsContainer graphicsContainer = iactiveView_0.GraphicsContainer;
            IMapFrame          frame             = graphicsContainer.FindFrame(iactiveView_0.FocusMap) as IMapFrame;

            graphicsContainer.Reset();
            IElement        item = graphicsContainer.Next();
            List <IElement> list = new List <IElement>();

            while (item != null)
            {
                if (item != frame)
                {
                    list.Add(item);
                }
                item = graphicsContainer.Next();
            }
            for (int i = 0; i < list.Count; i++)
            {
                try
                {
                    graphicsContainer.DeleteElement(list[i]);
                }
                catch
                {
                }
            }
        }
Пример #18
0
        private void ClearElements(IActiveView pActiveView)
        {
            IGraphicsContainer graphicsContainer = pActiveView.GraphicsContainer;
            IMapFrame          mapFrame          = graphicsContainer.FindFrame(pActiveView.FocusMap) as IMapFrame;

            (mapFrame as IMapGrids).ClearMapGrids();
            mapFrame.ExtentType = esriExtentTypeEnum.esriExtentDefault;
            graphicsContainer.Reset();
            IElement        element = graphicsContainer.Next();
            List <IElement> list    = new List <IElement>();

            while (element != null)
            {
                if (element != mapFrame)
                {
                    list.Add(element);
                }
                element = graphicsContainer.Next();
            }
            try
            {
                graphicsContainer.DeleteAllElements();
                graphicsContainer.Reset();
                element = graphicsContainer.Next();
                if (element != null)
                {
                    graphicsContainer.DeleteElement(element);
                }
                graphicsContainer.AddElement(mapFrame as IElement, -1);
                pActiveView.FocusMap = mapFrame.Map;
            }
            catch (Exception)
            {
            }
        }
Пример #19
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);
        }
Пример #20
0
        /// <summary>
        /// 从比例尺列表中,选择能够展示指定要素范围的最合适比例尺
        /// </summary>
        /// <param name="pageLayout">页面布局</param>
        /// <param name="mapFrame">要设定显示范围及比例尺的地图数据框</param>
        /// <param name="featureEnv">地图要素显示范围</param>
        /// <param name="scaleList">比例尺列表,将从中选取最合适的比例尺</param>
        /// <param name="bufferDistance">要素与图廓的缓冲距离(厘米),即地图实际显示范围是featEnvelope + 2 * bufferDistance</param>
        /// <returns></returns>
        public static double SetMapScale(this IPageLayout pageLayout, IMapFrame mapFrame,
                                         IEnvelope featureEnv, double[] scaleList, double bufferDistance = 2)
        {
            esriUnits pageUnit = pageLayout.Page.Units;
            esriUnits mapUnit  = mapFrame.Map.DistanceUnits;
            esriUnits cmUnit   = esriUnits.esriCentimeters; //厘米

            IEnvelope      mapFrameEnv   = (mapFrame as IElement)?.Geometry.Envelope;
            IUnitConverter unitConverter = new UnitConverterClass();
            double         wScale        = unitConverter.ConvertUnits(featureEnv.Width, mapUnit, cmUnit) / (unitConverter.ConvertUnits(mapFrameEnv.Width, pageUnit, cmUnit) - 2 * bufferDistance);
            double         hScale        = unitConverter.ConvertUnits(featureEnv.Height, mapUnit, cmUnit) / (unitConverter.ConvertUnits(mapFrameEnv.Height, pageUnit, cmUnit) - 2 * bufferDistance);
            double         dScale        = wScale > hScale ? wScale : hScale;

            int maxIndex = 0;

            while (maxIndex < scaleList.Length && dScale > scaleList[maxIndex])
            {
                maxIndex++;//寻找比要素全图廓显示所确定的比例尺小一级的比例尺
            }
            if (maxIndex == scaleList.Length)
            {
                throw new Exception("需要更小的比例尺!");
            }

            return(scaleList[maxIndex]);
        }
Пример #21
0
        public void makeScaleBar(IActiveView pActiveView, IPageLayout pPageLayout, IEnvelope pEnv)
        {
            IMap pMap = pActiveView.FocusMap;
            IGraphicsContainer pGraphicsContainer = pPageLayout as IGraphicsContainer;
            IMapFrame          pMapFrame          = pGraphicsContainer.FindFrame(pMap) as IMapFrame;

            if (pStyleGalleryItem == null)
            {
                return;
            }
            IMapSurroundFrame pMapSurroundFrame = new MapSurroundFrameClass();

            pMapSurroundFrame.MapFrame    = pMapFrame;
            pMapSurroundFrame.MapSurround = (IMapSurround)pStyleGalleryItem.Item;
            IElement pElement = axPageLayoutControl1.FindElementByName("ScaleBar");

            if (pElement != null)
            {
                pGraphicsContainer.DeleteElement(pElement);  //删除已经存在的比例尺
            }
            IElementProperties pElePro = null;

            pElement          = (IElement)pMapSurroundFrame;
            pElement.Geometry = (IGeometry)pEnv;
            pElePro           = pElement as IElementProperties;
            pElePro.Name      = "ScaleBar";
            pGraphicsContainer.AddElement(pElement, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Пример #22
0
        /// <summary>
        /// 设置地图为固定比例尺模式,并设定其比例尺(及显示范围和坐标系)
        /// </summary>
        /// <param name="mapFrame">地图数据框</param>
        /// <param name="nScale">比例尺</param>
        /// <param name="featureEnv">显示范围,值为null时不修改显示范围</param>
        /// <param name="spatialRef">坐标系,值为null是不修改坐标系</param>
        public static void SetMapScale(this IMapFrame mapFrame, double nScale,
                                       IEnvelope featureEnv = null, ISpatialReference spatialRef = null)
        {
            #region ArcGIS 9.3版本使用的代码
            //if (spatialRef != null)
            //    mapFrame.Map.SpatialReference = spatialRef;
            //if (featureEnv != null)
            //    (mapFrame.Map as IActiveView).Extent = featureEnv;
            //mapFrame.ExtentType = esriExtentTypeEnum.esriExtentScale;
            //mapFrame.MapScale = nScale;
            #endregion

            #region ArcGIS 10.0及以上版本使用的代码
            if (spatialRef != null)
            {
                mapFrame.Map.SpatialReference = spatialRef;
            }
            if (featureEnv != null)
            {
                ((IActiveView)mapFrame.Map).Extent = featureEnv;
            }
            IMapAutoExtentOptions mapAutoExtentOptions = mapFrame.Map as IMapAutoExtentOptions;
            mapAutoExtentOptions.AutoExtentType = esriExtentTypeEnum.esriExtentScale;//使用固定比例尺模式
            if (nScale != 0.0)
            {
                mapAutoExtentOptions.AutoExtentScale = nScale;
            }
            #endregion
        }
Пример #23
0
        /// <summary>
        /// 生成一个默认指北针
        /// </summary>
        /// <param name="pageLayoutControl"></param>
        /// <param name="startX"></param>
        /// <param name="startY"></param>
        /// <returns></returns>
        public static IMapSurround GetDefaultNortthArrow(IPageLayoutControlDefault pageLayoutControl, double startX, double startY)
        {
            try
            {
                IPageLayout pageLayout  = pageLayoutControl.PageLayout;
                IActiveView pActiveView = pageLayoutControl.ActiveView;
                IMap        map         = pActiveView.FocusMap;

                if (pageLayout == null || map == null)
                {
                    return(null);
                }
                IEnvelope envelope = new EnvelopeClass();
                envelope.PutCoords(startX, startY, startX + 48, startY + 48); //  Specify the location and size of the north arrow

                IUID uid = new UIDClass();
                uid.Value = "esriCarto.MarkerNorthArrow";

                // Create a Surround. Set the geometry of the MapSurroundFrame to give it a location
                IGraphicsContainer graphicsContainer = pageLayout as IGraphicsContainer;                                      // Dynamic Cast
                IActiveView        activeView        = pageLayout as IActiveView;                                             // Dynamic Cast
                IFrameElement      frameElement      = graphicsContainer.FindFrame(map);
                IMapFrame          mapFrame          = frameElement as IMapFrame;                                             // Dynamic Cast
                IMapSurroundFrame  mapSurroundFrame  = mapFrame.CreateSurroundFrame(uid as ESRI.ArcGIS.esriSystem.UID, null); // Dynamic Cast
                IElement           element           = mapSurroundFrame as IElement;                                          // Dynamic Cast
                element.Geometry = envelope;
                IMapSurround mapSurround = mapSurroundFrame.MapSurround;

                return(mapSurround);
            }
            catch (System.Exception ex)
            {
                return(null);
            }
        }
Пример #24
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);
         }
     }
 }
Пример #25
0
        public void add_grid()
        {
            activeView = pageLayoutControl.PageLayout as IActiveView;
            map        = activeView.FocusMap;

            IMapGrid      mapGrid;
            IMeasuredGrid measuredGrid;

            measuredGrid               = new MeasuredGrid() as IMeasuredGrid;
            mapGrid                    = measuredGrid as IMapGrid;
            measuredGrid.FixedOrigin   = true;
            measuredGrid.Units         = map.MapUnits;
            measuredGrid.XIntervalSize = 10;
            measuredGrid.YIntervalSize = 10;
            measuredGrid.XOrigin       = -180;
            measuredGrid.YOrigin       = -90;

            IProjectedGrid projectedGrid;

            projectedGrid = measuredGrid as IProjectedGrid;
            projectedGrid.SpatialReference = map.SpatialReference;
            mapGrid.Name = "Measured Grid";
            IMapFrame          mapFrame;
            IGraphicsContainer graphicsContainer;

            graphicsContainer = activeView as IGraphicsContainer;
            mapFrame          = graphicsContainer.FindFrame(map) as IMapFrame;
            IMapGrids mapGrids = mapFrame as IMapGrids;

            mapGrids.AddMapGrid(mapGrid);
            activeView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null);
        }
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            IActiveView pActiveView = (IActiveView)m_PageLayOutControl.PageLayout;

            IMap pMap = pActiveView.FocusMap;

            IGraphicsContainer pGraphicsContainer = (IGraphicsContainer)pActiveView;

            IMapFrame pMapFrame = (IMapFrame)pGraphicsContainer.FindFrame(pMap);

            IStyleSelector pStyleSelector = new BackgroundSelectorClass();

            bool m_bOK = pStyleSelector.DoModal(m_PageLayOutControl.hWnd);

            if (!m_bOK)
            {
                return;
            }

            IBackground pBackground = (IBackground)pStyleSelector.GetStyle(0);

            pMapFrame.Background = pBackground;

            m_PageLayOutControl.Refresh(esriViewDrawPhase.esriViewBackground, null, null);
        }
Пример #27
0
        /// <summary>
        /// Creates a new instance of DrawArgs
        /// </summary>
        public MapDrawArgs(Graphics inGraphics, Rectangle clipRectangle, IMapFrame inMapFrame)
        {
            _graphics = inGraphics;
            _geoGraphics = new MapArgs(clipRectangle, inMapFrame.ViewExtents);

            _clipRectangle = clipRectangle;
        }
        /// <summary>
        /// Reprojects all layers in the map frame so that they use the new
        /// projection ESRI string
        /// </summary>
        /// <param name="mapFrame">The map frame that contains all layers that should be reprojected</param>
        /// <param name="newProjEsriString">The ESRI WKT string of the new projection</param>
        public static void ReprojectMapFrame(IMapFrame mapFrame, string newProjEsriString)
        {
            //parse the projection
            ProjectionInfo newProjection = ProjectionInfo.FromEsriString(newProjEsriString);

            foreach (IMapLayer layer in mapFrame.GetAllLayers())
            {
                if (layer.DataSet.CanReproject)
                {
                    layer.DataSet.Reproject(newProjection);
                }
            }
            foreach (IMapGroup grp in mapFrame.GetAllGroups())
            {
                grp.Projection = ProjectionInfo.FromEsriString(newProjEsriString);
            }
            mapFrame.Projection = newProjection;

            var parent = mapFrame.Parent as IMap;
            if (parent != null)
            {
                // this need to fire Map.ProjectionChanged event
                parent.Projection = newProjection;
            } 
        }
Пример #29
0
        /// <summary>
        /// Gets all the layers of the given type.
        /// </summary>
        /// <typeparam name="T">Type of the layers that should be included.</typeparam>
        /// <param name="mapFrame">mapFrame that contains the layers.</param>
        /// <returns>The list of the layers with the given type.</returns>
        private static List <T> GetAllTypeLayers <T>(this IMapFrame mapFrame) where T : class
        {
            var layerList = new List <T>();

            GetNestedLayers <T>(mapFrame, layerList);
            return(layerList);
        }
Пример #30
0
 public bool SyncPageLayoutMainMapToMap(IPageLayout pPageLayout, ref IMap pMap, bool bClearElements)
 {
     try
     {
         if (pPageLayout == null)
         {
             return(false);
         }
         if (pMap == null)
         {
             return(false);
         }
         IMapFrame mapFrameMain = null;
         mapFrameMain = GISFunFactory.ElementFun.GetMapFrameMain(pPageLayout, "");
         if (mapFrameMain == null)
         {
             return(false);
         }
         IMap pSourceMap = mapFrameMain.Map;
         if (pSourceMap == null)
         {
             return(false);
         }
         this.SyncMapObject(pSourceMap, ref pMap, bClearElements);
         this.SyncMapExtent(pSourceMap, pMap, false);
         return(true);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.CoreFun", "SyncPageLayoutMainMapToMap", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(false);
     }
 }
Пример #31
0
        public void AddMapLegend(IPageLayout pageLayout, IMap map, System.Double posX, System.Double posY, System.Double legW)
        {
            try
            {
                if (pageLayout == null || map == null)
                {
                    return;
                }
                IGraphicsContainer          graphicsContainer = pageLayout as IGraphicsContainer;              // Dynamic Cast
                IMapFrame                   mapFrame          = graphicsContainer.FindFrame(map) as IMapFrame; // Dynamic Cast
                ESRI.ArcGIS.esriSystem.IUID uid = new ESRI.ArcGIS.esriSystem.UIDClass();
                uid.Value = "esriCarto.Legend";
                IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame((ESRI.ArcGIS.esriSystem.UID)uid, null); // Explicit Cast

                //Get aspect ratio
                IQuerySize    querySize = mapSurroundFrame.MapSurround as IQuerySize; // Dynamic Cast
                System.Double w         = 0;
                System.Double h         = 0;
                querySize.QuerySize(ref w, ref h);
                System.Double aspectRatio = w / h;

                IEnvelope envelope = new EnvelopeClass();

                envelope.PutCoords(posX, posY, (posX * legW), (posY * legW / aspectRatio));
                IElement element = mapSurroundFrame as IElement; // Dynamic Cast
                element.Geometry = envelope;
                graphicsContainer.AddElement(element, 0);
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
Пример #32
0
        /// <summary>
        /// 生成默认比例尺
        /// </summary>
        /// <param name="pageLayoutControl"></param>
        /// <param name="startX"></param>
        /// <param name="startY"></param>
        /// <returns></returns>
        public static IMapSurround GetDefaultScaleBar(IPageLayoutControlDefault pageLayoutControl, double startX, double startY)
        {
            try
            {
                IPageLayout        pageLayout = pageLayoutControl.PageLayout;
                IGraphicsContainer container  = pageLayout as IGraphicsContainer;
                IActiveView        activeView = pageLayout as IActiveView;
                // 获得MapFrame
                IFrameElement frameElement = container.FindFrame(activeView.FocusMap);
                IMapFrame     mapFrame     = frameElement as IMapFrame;
                //根据MapSurround的uid,创建相应的MapSurroundFrame和MapSurround
                UID uid = new UIDClass();
                uid.Value = "esriCarto.AlternatingScaleBar";
                IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uid, null);
                //设置MapSurroundFrame中比例尺的样式
                IMapSurround mapSurround    = mapSurroundFrame.MapSurround;
                IScaleBar    markerScaleBar = ((IScaleBar)mapSurround);
                markerScaleBar.LabelPosition = esriVertPosEnum.esriBelow;
                markerScaleBar.UseMapSettings();
                //QI,确定mapSurroundFrame的位置
                IElement  element  = mapSurroundFrame as IElement;
                IEnvelope envelope = new EnvelopeClass();
                envelope.PutCoords(startX, startY, startX + 10, startY + 10);
                element.Geometry = envelope;

                mapSurround = mapSurroundFrame.MapSurround;
                return(mapSurround);
            }
            catch (System.Exception ex)
            {
                return(null);
            }
        }
 /// <summary>
 /// use the mapFrame with this dialog
 /// </summary>
 /// <param name="mapFrame"></param>
 public MapFrameProjectionDialog(IMapFrame mapFrame)
 {
     InitializeComponent();
     _mapFrame = mapFrame;
     _projection = new ProjectionInfo();
     _projection.CopyProperties(_mapFrame.Projection);
     UpdateProjectionStrings();
 }
Пример #34
0
 /// <summary>
 /// use the mapFrame with this dialog
 /// </summary>
 /// <param name="mapFrame"></param>
 public MapFrameProjectionDialog(IMapFrame mapFrame)
 {
     InitializeComponent();
     lnkSpatialReference.Links[0].LinkData = "http://spatialreference.org/";
     tcMain.SelectTab(0);
     MapFrame = mapFrame;
     ChangesApplied = true;
 }
Пример #35
0
 /// <summary>
 /// Creates a new blank instance of a MapLayer collection.  This is especially useful
 /// for tracking layers that can draw themselves.  This does not concern itself with
 /// view extents like a dataframe, but rather is a grouping of layers that is itself
 /// also an IMapLayer.
 /// </summary>
 public MapLayerCollection(IMapFrame containerFrame)
 {
     base.MapFrame = containerFrame;
     ParentGroup = containerFrame;
 }
Пример #36
0
        /// <summary>
        /// Mouse Wheel
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseWheel(GeoMouseArgs e)
        {
 
            _zoomTimer.Stop(); // if the timer was already started, stop it.
            Rectangle r = e.Map.MapFrame.View;

            // For multiple zoom steps before redrawing, we actually
            // want the x coordinate relative to the screen, not
            // the x coordinate relative to the previously modified view.
            if (_client == Rectangle.Empty) _client = r;
            int cw = _client.Width;
            int ch = _client.Height;

            int w = r.Width;
            int h = r.Height;
            if (e.Delta > 0)
            {
                
                r.Inflate(-w / 4, -h / 4);
                // try to keep the mouse cursor in the same geographic position
                r.X += (e.X * w/(2*cw)) - w/4; 
                r.Y += (e.Y * w/(2*cw)) - h/4;
            }
            else
            {
                r.Inflate(w / 2, h / 2);
                r.X += w/2 - (e.X * w / cw);
                r.Y += h/2 - (e.Y * w / cw);

            }

            e.Map.MapFrame.View = r;
            e.Map.Invalidate();
            _zoomTimer.Start();
            _mapFrame = e.Map.MapFrame;
            base.OnMouseWheel(e);
        }
Пример #37
0
 /// <summary>
 /// Creates a new blank instance of a MapLayer collection.  This is especially useful
 /// for tracking layers that can draw themselves.  This does not concern itself with
 /// view extents like a dataframe, but rather is a grouping of layers that is itself
 /// also an IMapLayer.
 /// </summary>
 public MapLayerCollection(IMapFrame containerFrame, IProgressHandler progressHandler)
 {
     base.MapFrame = containerFrame;
     base.ParentGroup = containerFrame;
     _progressHandler = progressHandler;
 }
Пример #38
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add ChangeFrameBackGround.OnClick implementation
              // IActiveView pActiveView;
               //IGraphicsContainer pGraphicsContainer;

              //  IMap pMap;
               // pActiveView = m_pageLayoutControl.PageLayout as IActiveView;
              ///  pMap = pActiveView.FocusMap;
               // pGraphicsContainer = pActiveView as IGraphicsContainer;

               // pMapFrame = pGraphicsContainer.FindFrame(pMap) as IMapFrame;
              //  IStyleSelector pStyleSelector;
               // pStyleSelector = new BackgroundSelectorClass();
            //􁰒􂼎􄗝􁢽􁇍􄈵􁸚􁇍􄈵􃒭􂫼􁠋
               // bool m_bOK;
              //  m_bOK = pStyleSelector.DoModal(m_pageLayoutControl.hWnd);

            //􁔧􂫼􁠋􁣝􀏟(cancel􁯊􄗔􀟎􄖛􂿟)
               // if (!m_bOK) return;
              //  IBackground pBackground;
            //􃦋􁕫􀏔􀏾􃚠􁱃􁇍􄈵
               // pBackground = pStyleSelector.GetStyle(0) as IBackground;
            //􄆒􃕂
            if (m_element is IMapFrame)
                m_MapFrame = m_element as IMapFrame;
            frmLegendItemSymbol frmBackGround=new frmLegendItemSymbol();
            ESRI.ArcGIS.Controls.esriSymbologyStyleClass  styleClass= esriSymbologyStyleClass.esriStyleClassBackgrounds ;
               IStyleGalleryItem  pStyleGalleryItem=  frmBackGround .GetItem (styleClass );
               if (pStyleGalleryItem != null)
               m_MapFrame.Background = (IBackground)pStyleGalleryItem.Item;
               else
               return;
               // pMapFrame.Background = pBackground;
            //􀠋􁮄􃚠􁱃

               m_PageLayoutControl.Refresh(esriViewDrawPhase.esriViewBackground, null, null);
               m_PageLayoutControl.ActiveView.Refresh();
        }
Пример #39
0
 /// <summary>
 /// Creates the Collection in the situation where the map frame is not the immediate parent,
 /// but rather the group is the immediate parent, while frame is the ultimate map frame that
 /// contains this geo layer collection.
 /// </summary>
 /// <param name="frame"></param>
 /// <param name="group"></param>
 /// <param name="progressHandler"></param>
 public MapLayerCollection(IMapFrame frame, IMapGroup group, IProgressHandler progressHandler)
 {
     base.MapFrame = frame;
     ParentGroup = group;
     _progressHandler = progressHandler;
 }
Пример #40
0
 /// <summary>
 /// Handles removing event handlers for the map frame
 /// </summary>
 /// <param name="mapFrame"></param>
 protected virtual void OnExcludeMapFrame(IMapFrame mapFrame)
 {
     if (mapFrame == null) return;
     mapFrame.UpdateMap -= MapFrameUpdateMap;
     mapFrame.ScreenUpdated -= MapFrameScreenUpdated;
     mapFrame.ItemChanged -= MapFrameItemChanged;
     mapFrame.BufferChanged -= MapFrame_BufferChanged;
     mapFrame.SelectionChanged -= MapFrame_SelectionChanged;
     mapFrame.LayerAdded -= MapFrame_LayerAdded;
     mapFrame.ViewExtentsChanged -= MapFrame_ViewExtentsChanged;
     if (Legend != null)
     {
         Legend.RemoveMapFrame(mapFrame, true);
     }
 }
Пример #41
0
 protected override void OnIncludeMapFrame(IMapFrame mapFrame)
 {
     if (mapFrame == null) return;
     mapFrame.ViewChanged += MapFrameViewChanged;
     base.OnIncludeMapFrame(mapFrame);
 }
Пример #42
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add ChangeFrameBorder.OnClick implementation
            /*
            IActiveView pActiveView;
            IGraphicsContainer pGraphicsContainer;
            IMapFrame pMapFrame;
            IMap pMap;
            pActiveView = m_pageLayoutControl.PageLayout as IActiveView;
            pMap = pActiveView.FocusMap;
            pGraphicsContainer = pActiveView as IGraphicsContainer;
            pMapFrame = pGraphicsContainer.FindFrame(pMap) as IMapFrame;
            IStyleSelector pStyleSelector;
            //􁮄􁓎􀏔􀏾􄖍􁸚􄗝􁢽􀰼􁇍􄈵
            pStyleSelector = new BorderSelectorClass();
            bool m_bOK;
            m_bOK = pStyleSelector.DoModal(m_pageLayoutControl.hWnd);
            if (!m_bOK) return;
            IBorder pBorder;
            pBorder = pStyleSelector.GetStyle(0) as IBorder; //􁕫􀠄􀏔􀏾 IBorder􁇍􄈵
               */
            IElementProperties pElementProties = m_element as IElementProperties;
            if (m_element is IMapFrame)
            {
                m_MapFrame = m_element as IMapFrame;
            }
            else if (pElementProties.Type == "Map Surround Frame")
            {
             IMapSurroundFrame pMapSurrounFrame = pElementProties as IMapSurroundFrame;
             if (pMapSurrounFrame.MapSurround.Name == "Legend")
             {
                 //ILegend pLegend = m_element as ILegend;
                 //为了改变边框,背景,阴影等样式
                 //IMapSurround pmapSurd = (IMapSurround)pLegend;
                 IMapSurroundFrame pmapSurdFrm = pMapSurrounFrame ;
               //  pmapSurdFrm.MapSurround = pmapSurd;
                 IMapFrame pMapFrm = new MapFrameClass();
                 pMapFrm = pmapSurdFrm.MapFrame;
                 m_MapFrame = pMapFrm;
             }
             else if (pMapSurrounFrame.MapSurround.Name == "Alternating Scale Bar")
             {
                // IScaleBar pScaleBatr = m_element as IScaleBar;
                // IMapSurround pmapSurd = (IMapSurround)pScaleBatr ;
                 IMapSurroundFrame pmapSurdFrm = pMapSurrounFrame;
               //  pmapSurdFrm.MapSurround = pmapSurd;
                 IMapFrame pMapFrm = new MapFrameClass();
                 pMapFrm = pmapSurdFrm.MapFrame;
                 m_MapFrame = pMapFrm;
             }
             else if (pMapSurrounFrame.MapSurround.Name == "Scale Text")
             {
                 //IScaleText pScaleText = m_element as IScaleText;
                // IMapSurround pmapSurd = (IMapSurround)pScaleText;
                 IMapSurroundFrame pmapSurdFrm = pMapSurrounFrame;
                 //pmapSurdFrm.MapSurround = pmapSurd;
                 IMapFrame pMapFrm = new MapFrameClass();
                 pMapFrm = pmapSurdFrm.MapFrame;
                 m_MapFrame = pMapFrm;
             }
             else if (pMapSurrounFrame.MapSurround.Name == "North Arrow")
             {
                // INorthArrow pNorthArrow = m_element as INorthArrow;
               //  IMapSurround pmapSurd = (IMapSurround)pNorthArrow ;
                 IMapSurroundFrame pmapSurdFrm = pMapSurrounFrame;
                // pmapSurdFrm.MapSurround = pmapSurd;
                 IMapFrame pMapFrm = new MapFrameClass();
                 pMapFrm = pmapSurdFrm.MapFrame;
                 m_MapFrame = pMapFrm;
             }

            }

            frmLegendItemSymbol frmBackGround = new frmLegendItemSymbol();
            ESRI.ArcGIS.Controls.esriSymbologyStyleClass styleClass = esriSymbologyStyleClass.esriStyleClassBorders ;
            IStyleGalleryItem pStyleGalleryItem = frmBackGround.GetItem(styleClass);
            if (pStyleGalleryItem != null)
                m_MapFrame.Border = (IBorder )pStyleGalleryItem.Item;
            else
                return;
            m_pageLayoutControl.Refresh(esriViewDrawPhase.esriViewBackground, null, null);
        }
Пример #43
0
        /// <summary>
        /// Mouse Wheel
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseWheel(GeoMouseArgs e) //Fix this
        {
            _zoomTimer.Stop(); // if the timer was already started, stop it.

            Extent MaxExtent = e.Map.GetMaxExtent();
         
            if ((e.Map.IsZoomedToMaxExtent == true) && (_direction * e.Delta < 0))
            {}
            else
            {
                e.Map.IsZoomedToMaxExtent = false;
                Rectangle r = e.Map.MapFrame.View;

                // For multiple zoom steps before redrawing, we actually
                // want the x coordinate relative to the screen, not
                // the x coordinate relative to the previously modified view.
                if (_client == Rectangle.Empty)
                {
                    _client = r;
                }
                int cw = _client.Width;
                int ch = _client.Height;

                double w = r.Width;
                double h = r.Height;

                if (_direction * e.Delta > 0)
                {

                    double inFactor = 2.0 * _sensitivity;
                    r.Inflate(Convert.ToInt32(-w / inFactor), Convert.ToInt32(-h / inFactor));
                    // try to keep the mouse cursor in the same geographic position
                    r.X += Convert.ToInt32((e.X * w / (_sensitivity * cw)) - w / inFactor);
                    r.Y += Convert.ToInt32((e.Y * h / (_sensitivity * ch)) - h / inFactor);

                }
                else
                {
                    double outFactor = 0.5 * _sensitivity;
                    r.Inflate(Convert.ToInt32(w / _sensitivity), Convert.ToInt32(h / _sensitivity));
                    r.X += Convert.ToInt32(w / _sensitivity - (e.X * w / (outFactor * cw)));
                    r.Y += Convert.ToInt32(h / _sensitivity - (e.Y * h / (outFactor * ch)));
                }
                int mapHeight = e.Map.MapFrame.View.Height;
                int mapWidth = e.Map.MapFrame.View.Width;


                e.Map.MapFrame.View = r;
                e.Map.Invalidate();
                _zoomTimer.Start();
                _mapFrame = e.Map.MapFrame;
                if (!BusySet)
                {
                    Map.IsBusy = true;
                    BusySet = true;
                }
                base.OnMouseWheel(e);

            }

        }
Пример #44
0
 /// <summary>
 /// Handles adding new event handlers to the map frame
 /// </summary>
 /// <param name="mapFrame"></param>
 protected virtual void OnIncludeMapFrame(IMapFrame mapFrame)
 {
     if (mapFrame == null)
     {
         if (Legend == null) return;
         Legend.RefreshNodes();
         return;
     }
     mapFrame.Parent = this;
     mapFrame.UpdateMap += MapFrameUpdateMap;
     mapFrame.ScreenUpdated += MapFrameScreenUpdated;
     mapFrame.ItemChanged += MapFrameItemChanged;
     mapFrame.BufferChanged += MapFrame_BufferChanged;
     mapFrame.SelectionChanged += MapFrame_SelectionChanged;
     mapFrame.LayerAdded += MapFrame_LayerAdded;
     mapFrame.ViewExtentsChanged += MapFrame_ViewExtentsChanged;
     if (Legend == null) return;
     Legend.AddMapFrame(mapFrame);
 }
Пример #45
0
 /// <summary>
 /// Occurs when this command is clicked
 /// </summary>
 public override void OnClick()
 {
     // TODO: Add ChangeFrameShadow.OnClick implementation
        /* IActiveView pActiveView;
     IGraphicsContainer pGraphicsContainer;
     IMapFrame pMapFrame;
     IMap pMap;
     pActiveView = m_pageLayoutControl.PageLayout as IActiveView;
     pMap = pActiveView.FocusMap;
     pGraphicsContainer = pActiveView as IGraphicsContainer;
     pMapFrame = pGraphicsContainer.FindFrame(pMap) as IMapFrame;
     IStyleSelector pStyleSelector;
     pStyleSelector = new ShadowSelectorClass();
     //􁰒􂼎􄗝􁢽􁇍􄈵􁸚􁇍􄈵􃒭􂫼􁠋
     bool m_bOK;
     m_bOK = pStyleSelector.DoModal(m_pageLayoutControl.hWnd);
     //􀽖􁵰􂫼􁠋􁣝cancel􁣝􄪂􀟭􄗔􀟎
     if (!m_bOK) return;
     IShadow pShadow;
     //􀒢􄗝􁢽􀰼􀐁􁕫􀠄􀏔􀏾IShadow􁇍􄈵
     pShadow = pStyleSelector.GetStyle(0) as IShadow;
     IFrameProperties pFrameProperties;
     pFrameProperties = pMapFrame as IFrameProperties;
     //􄆒􃕂*/
     IElementProperties pElementProties = m_element as IElementProperties;
     if (m_element is IMapFrame)
         m_MapFrame = m_element as IMapFrame;
     else if (pElementProties.Type == "Map Surround Frame")
     {
         IMapSurroundFrame pMapSurrounFrame = pElementProties as IMapSurroundFrame;
         if (pMapSurrounFrame.MapSurround.Name == "Legend")
         {
             //ILegend pLegend = m_element as ILegend;
             //为了改变边框,背景,阴影等样式
             //IMapSurround pmapSurd = (IMapSurround)pLegend;
             IMapSurroundFrame pmapSurdFrm = pMapSurrounFrame;
             //  pmapSurdFrm.MapSurround = pmapSurd;
             IMapFrame pMapFrm = new MapFrameClass();
             pMapFrm = pmapSurdFrm.MapFrame;
             m_MapFrame = pMapFrm;
         }
         else if (pMapSurrounFrame.MapSurround.Name == "Alternating Scale Bar")
         {
             // IScaleBar pScaleBatr = m_element as IScaleBar;
             // IMapSurround pmapSurd = (IMapSurround)pScaleBatr ;
             IMapSurroundFrame pmapSurdFrm = pMapSurrounFrame;
             //  pmapSurdFrm.MapSurround = pmapSurd;
             IMapFrame pMapFrm = new MapFrameClass();
             pMapFrm = pmapSurdFrm.MapFrame;
             m_MapFrame = pMapFrm;
         }
         else if (pMapSurrounFrame.MapSurround.Name == "Scale Text")
         {
             //IScaleText pScaleText = m_element as IScaleText;
             // IMapSurround pmapSurd = (IMapSurround)pScaleText;
             IMapSurroundFrame pmapSurdFrm = pMapSurrounFrame;
             //pmapSurdFrm.MapSurround = pmapSurd;
             IMapFrame pMapFrm = new MapFrameClass();
             pMapFrm = pmapSurdFrm.MapFrame;
             m_MapFrame = pMapFrm;
         }
         else if (pMapSurrounFrame.MapSurround.Name == "North Arrow")
         {
             // INorthArrow pNorthArrow = m_element as INorthArrow;
             //  IMapSurround pmapSurd = (IMapSurround)pNorthArrow ;
             IMapSurroundFrame pmapSurdFrm = pMapSurrounFrame;
             // pmapSurdFrm.MapSurround = pmapSurd;
             IMapFrame pMapFrm = new MapFrameClass();
             pMapFrm = pmapSurdFrm.MapFrame;
             m_MapFrame = pMapFrm;
         }
     }
     IFrameProperties pFrameProperties;
     pFrameProperties =m_MapFrame as IFrameProperties;
     frmLegendItemSymbol frmBackGround = new frmLegendItemSymbol();
     ESRI.ArcGIS.Controls.esriSymbologyStyleClass styleClass = esriSymbologyStyleClass.esriStyleClassShadows ;
     IStyleGalleryItem pStyleGalleryItem = frmBackGround.GetItem(styleClass);
     if (pStyleGalleryItem != null)
         pFrameProperties .Shadow  = (IShadow )pStyleGalleryItem.Item;
     else
         return;
        // pFrameProperties.Shadow = pShadow;
     m_pageLayoutControl.Refresh (esriViewDrawPhase.esriViewBackground, null, null);
     m_pageLayoutControl.ActiveView.Refresh();
 }