/// <summary> /// 在布局中添加一个地图数据框 /// </summary> private void AddDataFrame(FrmLayoutPage dialog) { IMap pMap = new MapClass(); pMap.Name = "New Map"; IMapFrame pMapFrame = new MapFrameClass(); pMapFrame.Map = pMap; IElement pElement = pMapFrame as IElement; IEnvelope pEnv = new EnvelopeClass(); //设置一个默认的地图框大小 pEnv.PutCoords(0, 0, 5, 5); pElement.Geometry = pEnv; IGraphicsContainer pGraphicsContainer = dialog.PageControl.GraphicsContainer; pGraphicsContainer.AddElement(pElement, 0); IActiveView pActiveView = dialog.PageControl.ActiveView; pActiveView.FocusMap = pMap; }
private void axPageLayoutControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IPageLayoutControlEvents_OnMouseDownEvent e) { if (e.button == 1) { return; } //Create an envelope by tracking a rectangle IEnvelope envelope = axPageLayoutControl1.TrackRectangle(); //Create a map frame element with a new map IMapFrame mapFrame = new MapFrameClass(); mapFrame.Map = new MapClass(); //Add the map frame to the PageLayoutControl with specified geometry axPageLayoutControl1.AddElement((IElement)mapFrame, envelope, null, null, 0); //Refresh the PageLayoutControl axPageLayoutControl1.Refresh(esriViewDrawPhase.esriViewGraphics, null, null); }
/// <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(); }
private void axPageLayoutControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IPageLayoutControlEvents_OnMouseDownEvent e) { if (e. button == 1) return; //Create an envelope by tracking a rectangle IEnvelope envelope = axPageLayoutControl1.TrackRectangle(); //Create a map frame element with a new map IMapFrame mapFrame = new MapFrameClass(); mapFrame.Map = new MapClass(); //Add the map frame to the PageLayoutControl with specified geometry axPageLayoutControl1.AddElement((IElement)mapFrame, envelope, null, null, 0); //Refresh the PageLayoutControl axPageLayoutControl1.Refresh(esriViewDrawPhase.esriViewGraphics, null, null); }
/// <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); }
/// <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); }
private void GeneratePageLayout() { IPageLayout pageLayout = axPageLayoutControl1.PageLayout; IGraphicsContainer pGraphicsContainer = pageLayout as IGraphicsContainer; pGraphicsContainer.DeleteAllElements(); IPage pPage = new PageClass(); pPage = pageLayout.Page; pPage.PutCustomSize(36, 24); IActiveView pActiveView = pageLayout as IActiveView; IMap pMap = pActiveView.FocusMap; IMapFrame mapFrame1 = pGraphicsContainer.FindFrame(pMap) as IMapFrame; IEnvelope pEnvelope = new EnvelopeClass(); pEnvelope.PutCoords(1.5, 3, 17.5, 20); IElement pElement = mapFrame1 as IElement; pElement.Geometry = pEnvelope; //Map frame 2 IMap mapDF1 = new MapClass(); IMapFrame mapFrame2 = new MapFrameClass(); mapFrame2.Map = mapDF1; IElement element1 = mapFrame2 as IElement; IEnvelope envelope1 = new EnvelopeClass(); envelope1.PutCoords(18.5, 3, 34.5, 20); element1.Geometry = envelope1; //?????element 1 or bot map always hide??? pGraphicsContainer.AddElement(element1, 0); //# //////add map---problem shot //mapFrame1.Map = m_MapControltop.ActiveView.FocusMap; //mapFrame2.Map = m_MapControlbase.ActiveView.FocusMap; //# //TRY to use ObjectCopy //copy map to top mapframe of pagelayoutcontrol IObjectCopy objectCopy1 = new ObjectCopyClass(); object toCopyMap1 = m_MapControltop.ActiveView.FocusMap; //IMap map1 = toCopyMap1 as IMap; //map1.IsFramed = true; object copiedMap1 = objectCopy1.Copy(toCopyMap1); object toOverwriteMap1 = mapFrame1.Map; objectCopy1.Overwrite(copiedMap1, ref toOverwriteMap1); //SetMapExtent1(); //copy map to bot mapframe of pagelayoutcontrol IObjectCopy objectCopy2 = new ObjectCopyClass(); object toCopyMap2 = m_MapControlbase.ActiveView.FocusMap; object copiedMap2 = objectCopy2.Copy(toCopyMap2); object toOverwriteMap2 = mapFrame2.Map; objectCopy2.Overwrite(copiedMap2, ref toOverwriteMap2); mapFrame1.Map.Name = "MapTop"; mapFrame2.Map.Name = "MapBot"; //try to change scale IGraphicsContainer container = this.axPageLayoutControl1.GraphicsContainer; container.Reset(); IElement element = container.Next(); int index = 0; while (element != null) { if (element is IMapFrame) { IMapFrame mapFrame = (IMapFrame)element; string sMapName = mapFrame.Map.Name; IElementProperties elementProperties = (IElementProperties)element; string slementName = elementProperties.Name; index += 1; } element = container.Next(); } //add title ITextElement teTitle = new TextElementClass(); IPoint ptTitle = new PointClass(); ptTitle.PutCoords(18, 22.5); IElement eleTitle = teTitle as IElement; eleTitle = MakeATextElement(ptTitle, tbStNum.Text + " " + tbStNa.Text + " Historical Aerial Comparison", 80); pGraphicsContainer.AddElement(eleTitle, 0); string topYear = cboTopYear.Text; string botYear = cboBotYear.Text; //Add subtitle ITextElement teSubTitle1 = new TextElementClass(); IPoint ptSubTitle1 = new PointClass(); ptSubTitle1.PutCoords(9.5, 21); IElement eleSubTitle1 = teSubTitle1 as IElement; eleSubTitle1 = MakeATextElement(ptSubTitle1, topYear, 45); pGraphicsContainer.AddElement(eleSubTitle1, 0); //Add Subtitle2 ITextElement teSubTitle2 = new TextElementClass(); IPoint ptSubTitle2 = new PointClass(); ptSubTitle2.PutCoords(26.5, 21); IElement eleSubTitle2 = teSubTitle2 as IElement; eleSubTitle2 = MakeATextElement(ptSubTitle2, botYear, 45); pGraphicsContainer.AddElement(eleSubTitle2, 0); //Add Scale Bar AddScaleBar(mapFrame1.Map); //Add North Arrow AddNorthArrow(axPageLayoutControl1.PageLayout, mapFrame1.Map); axPageLayoutControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); MessageBox.Show("Done!"); }
/// <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(); }