public void AddScaleBar() { IGraphicsContainer graphicsContainer = m_pagelayoutControl.GraphicsContainer; //Get the MapFrame IMapFrame mapFrame = (IMapFrame)graphicsContainer.FindFrame(m_pagelayoutControl.ActiveView.FocusMap); if (mapFrame == null) { return; } //Create a legend UID uID = new UIDClass(); uID.Value = "esriCarto.ScaleLine"; //Create a MapSurroundFrame from the MapFrame IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uID, null); if (mapSurroundFrame == null) { return; } if (mapSurroundFrame.MapSurround == null) { return; } // m_styleSelector = new ScaleBarSelectorClass(); IEnvelope m_envelop = new EnvelopeClass(); m_envelop.PutCoords(5, 5, 10, 10); ESRI.ArcGIS.Controls.esriSymbologyStyleClass styleClass = esriSymbologyStyleClass.esriStyleClassScaleBars; frmLegendItemSymbol frmScaleBar = new frmLegendItemSymbol(); IStyleGalleryItem pstyGallertItem = frmScaleBar.GetItem(styleClass); if (pstyGallertItem == null) { return; } IScaleBar pScalebar = pstyGallertItem.Item as IScaleBar; pScalebar.Units = m_pagelayoutControl.ActiveView.FocusMap.MapUnits; pScalebar.Map = m_pagelayoutControl.ActiveView.FocusMap; pScalebar.UseMapSettings(); IMapSurround m_mapSurround; m_mapSurround = (IMapSurround)pScalebar; mapSurroundFrame.MapSurround = m_mapSurround; IElement m_element = (IElement)mapSurroundFrame; m_element.Geometry = m_envelop; m_pagelayoutControl.AddElement(m_element, Type.Missing, Type.Missing, "ScaleLine", 3); m_pagelayoutControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
private void btnLegendSymbol_Click(object sender, EventArgs e) { //未设置成功?????????????? frmLegendItemSymbol frmLengendSymbol = new frmLegendItemSymbol(); ESRI.ArcGIS.Controls.esriSymbologyStyleClass pStyleClass = ESRI.ArcGIS.Controls.esriSymbologyStyleClass.esriStyleClassLegendItems; IStyleGalleryItem pStyleGalleryItem = frmLengendSymbol.GetItem(pStyleClass); // pTextSymbol = frmLengendSymbol.pTextSymbol; }
public void AddTextScale() { IGraphicsContainer graphicsContainer = m_pagelayoutControl.GraphicsContainer; //Get the MapFrame IMapFrame mapFrame = (IMapFrame)graphicsContainer.FindFrame(m_pagelayoutControl.ActiveView.FocusMap); if (mapFrame == null) { return; } //Create a legend UID uID = new UIDClass(); uID.Value = "esriCarto.ScaleText"; //Create a MapSurroundFrame from the MapFrame IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uID, null); if (mapSurroundFrame == null) { return; } if (mapSurroundFrame.MapSurround == null) { return; } IEnvelope m_envelop = new EnvelopeClass(); m_envelop.PutCoords(15, 15, 20, 20); frmLegendItemSymbol frmTextScal = new frmLegendItemSymbol(); IStyleGalleryItem pStyGalleryItem = frmTextScal.GetItem(esriSymbologyStyleClass.esriStyleClassScaleTexts); IScaleText pScaleText = null; if (pStyGalleryItem != null) { pScaleText = (IScaleText)pStyGalleryItem.Item; pScaleText.Map = this.m_pagelayoutControl.ActiveView.FocusMap; pScaleText.MapUnits = this.m_pagelayoutControl.ActiveView.FocusMap.MapUnits; } else { return; } IMapSurround m_mapSurround; m_mapSurround = (IMapSurround)pScaleText; mapSurroundFrame.MapSurround = m_mapSurround; IElement m_element = (IElement)mapSurroundFrame; m_element.Geometry = m_envelop; m_pagelayoutControl.AddElement(m_element, Type.Missing, Type.Missing, "ScaleText", 4); m_pagelayoutControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
private void btnArea_Click(object sender, EventArgs e) { frmLegendItemSymbol frmAreaSymbol = new frmLegendItemSymbol(); //Get the IStyleGalleryItem that has been selected in the SymbologyControl IStyleGalleryItem styleGalleryItem = frmAreaSymbol.GetItem(esriSymbologyStyleClass.esriStyleClassAreaPatches); //change the default area (面样式)patch plegendFormat.DefaultAreaPatch = (IAreaPatch)styleGalleryItem.Item; }
private void btnLine_Click(object sender, EventArgs e) { frmLegendItemSymbol frmAreaSymbol = new frmLegendItemSymbol(); //Get the IStyleGalleryItem that has been selected in the SymbologyControl IStyleGalleryItem styleGalleryItem = frmAreaSymbol.GetItem(esriSymbologyStyleClass.esriStyleClassLinePatches); //change the default line(线样式) patch if (styleGalleryItem != null) { plegendFormat.DefaultLinePatch = (ILinePatch)styleGalleryItem.Item; } else { return; } }
/// <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(); }
private void button5_Click(object sender, EventArgs e) { Color pColor; frmLegendItemSymbol frmShadow = new frmLegendItemSymbol(); IStyleGalleryItem pStyleGalleryItem = frmShadow.GetItem(esriSymbologyStyleClass.esriStyleClassShadows); if (pStyleGalleryItem != null) { m_SymbolShadow = (ISymbolShadow)pStyleGalleryItem.Item; pColor = this.ConvertIRgbColorToColor(((ISymbolShadow)pStyleGalleryItem.Item).FillSymbol.Color as IRgbColor); } else { m_SymbolShadow = new SymbolShadowClass(); pColor = Color.White; } this.btnShadowColor.BackColor = pColor; IStyleGalleryClass pStyleGalleryClass = new ShadowStyleGalleryClassClass(); Bitmap pBitmap = StyleGalleryItemToBmp(this.pictureBox3.Width, this.pictureBox3.Height, pStyleGalleryClass, pStyleGalleryItem); this.pictureBox3.Image = pBitmap as Image; }
private void btnChangeBCStyle_Click(object sender, EventArgs e) { Color pColor; frmLegendItemSymbol frmBolder = new frmLegendItemSymbol(); IStyleGalleryItem pStyleGalleryItem = frmBolder.GetItem(esriSymbologyStyleClass.esriStyleClassBorders); if (pStyleGalleryItem != null) { m_SymbolBorder = (ISymbolBorder)pStyleGalleryItem.Item; pColor = this.ConvertIRgbColorToColor(((ISymbolBorder )pStyleGalleryItem.Item).LineSymbol.Color as IRgbColor); } else { m_SymbolBorder = new SymbolBorderClass(); pColor = Color.White; } this.btnBolderColor.BackColor = pColor; IStyleGalleryClass pStyleGalleryClass = new BorderStyleGalleryClassClass(); Bitmap pBitmap = StyleGalleryItemToBmp(this.pictureBox2.Width, this.pictureBox2.Height, pStyleGalleryClass, pStyleGalleryItem); this.pictureBox2.Image = pBitmap as Image; }
private void btrChangBorderStlye_Click(object sender, EventArgs e) { Color pColor; frmLegendItemSymbol frmBackColor = new frmLegendItemSymbol(); IStyleGalleryItem pStyleGalleryItem = frmBackColor.GetItem(esriSymbologyStyleClass.esriStyleClassBackgrounds); if (pStyleGalleryItem != null) { m_SymbolBackground = (ISymbolBackground)pStyleGalleryItem.Item; pColor = this.ConvertIRgbColorToColor(((ISymbolBackground )pStyleGalleryItem.Item).FillSymbol.Color as IRgbColor); } else { m_SymbolBackground = new SymbolBackgroundClass(); pColor = Color.White; } this.btnBackGroundColor.BackColor = pColor; IStyleGalleryClass pStyleGalleryClass = new BackgroundStyleGalleryClassClass(); Bitmap pBitmap = StyleGalleryItemToBmp(this.pictureBox1.Width, this.pictureBox1.Height, pStyleGalleryClass, pStyleGalleryItem); this.pictureBox1.Image = pBitmap as Image; }
/// <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 axPageLayoutControl1_OnDoubleClick(object sender, IPageLayoutControlEvents_OnDoubleClickEvent e) { if (m_element != null) { IElementProperties pElementProp = m_element as IElementProperties; if (pElementProp.Type == "Text") { ITextElement pTextElement = pElementProp as ITextElement; frmTextSymbol frmText = new frmTextSymbol(ref pTextElement); frmText.ShowDialog(); pElementProp = pTextElement as IElementProperties; m_pageLayoutControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphicSelection, null, null); m_pageLayoutControl.ActiveView.Refresh(); } else if (pElementProp.Type == "Map Surround Frame") { IMapSurroundFrame pMapSurrounFrame = pElementProp as IMapSurroundFrame; if (pMapSurrounFrame.MapSurround.Name == "Legend") { frmLegendWizard frmLegedWizard = new frmLegendWizard(m_Map, m_pageLayoutControl, pMapSurrounFrame); frmLegedWizard.ShowDialog(); //修改图例属性 } else if (pMapSurrounFrame.MapSurround.Name == "Alternating Scale Bar" || pMapSurrounFrame.MapSurround.Name == "Hollow Scale Bar" || pMapSurrounFrame.MapSurround.Name == "Double lternating Scale Bar" || pMapSurrounFrame.MapSurround.Name == "Scale Line" || pMapSurrounFrame.MapSurround.Name == "Single Division Scale Bar" || pMapSurrounFrame.MapSurround.Name == "Stepped Scale Line") { ESRI.ArcGIS.Controls.esriSymbologyStyleClass styleClass = esriSymbologyStyleClass.esriStyleClassScaleBars; frmLegendItemSymbol frmScaleBar = new frmLegendItemSymbol(); IStyleGalleryItem pstyGallertItem = frmScaleBar.GetItem(styleClass);//获取样式 IScaleBar pscaleBar = pMapSurrounFrame.MapSurround as IScaleBar; esriUnits punits = pscaleBar.Units; if (pstyGallertItem != null) { pscaleBar = (IScaleBar)pstyGallertItem.Item; } else { return; } pscaleBar.Map = m_pageLayoutControl.ActiveView.FocusMap; //重新设置比例尺依附的地图及单位 pscaleBar.Units = punits; pscaleBar.UseMapSettings(); pscaleBar.Refresh(); pMapSurrounFrame.MapSurround = pscaleBar as IMapSurround; //旧的比例尺样式转换为新的比例尺样式 m_pageLayoutControl.Refresh(esriViewDrawPhase.esriViewGraphics, null, null); //刷新 } else if (pMapSurrounFrame.MapSurround.Name == "Scale Text") { frmLegendItemSymbol frmTextScal = new frmLegendItemSymbol(); IStyleGalleryItem pStyGalleryItem = frmTextScal.GetItem(esriSymbologyStyleClass.esriStyleClassScaleTexts); IScaleText pScaleText = pMapSurrounFrame.MapSurround as IScaleText; esriUnits pUnits = pScaleText.MapUnits; if (pStyGalleryItem != null) { pScaleText = (IScaleText)pStyGalleryItem.Item; } else { return; } pScaleText.Map = m_pageLayoutControl.ActiveView.FocusMap; pScaleText.MapUnits = pScaleText.MapUnits; pMapSurrounFrame.MapSurround = pScaleText as IMapSurround; m_pageLayoutControl.Refresh(esriViewDrawPhase.esriViewGraphics, null, null); } else if (pMapSurrounFrame.MapSurround.Name.Trim() == "North Arrow") { INorthArrow northArrow = pMapSurrounFrame.MapSurround as INorthArrow; frmNorthArrowSymbol frmNorthArrow = new frmNorthArrowSymbol(); IStyleGalleryItem pstyGallertItem = frmNorthArrow.GetItem(esriSymbologyStyleClass.esriStyleClassNorthArrows);; if (pstyGallertItem != null) { northArrow = (INorthArrow)pstyGallertItem.Item; northArrow.CalibrationAngle = frmNorthArrow.Angle(); } else { return; } pMapSurrounFrame.MapSurround = (IMapSurround)northArrow; m_pageLayoutControl.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 button5_Click(object sender, EventArgs e) { Color pColor; frmLegendItemSymbol frmShadow = new frmLegendItemSymbol(); IStyleGalleryItem pStyleGalleryItem = frmShadow.GetItem(esriSymbologyStyleClass.esriStyleClassShadows); if (pStyleGalleryItem != null) { m_SymbolShadow = (ISymbolShadow)pStyleGalleryItem.Item; pColor = this.ConvertIRgbColorToColor(((ISymbolShadow)pStyleGalleryItem.Item).FillSymbol.Color as IRgbColor); } else { m_SymbolShadow = new SymbolShadowClass(); pColor = Color.White; } this.btnShadowColor .BackColor = pColor; IStyleGalleryClass pStyleGalleryClass = new ShadowStyleGalleryClassClass (); Bitmap pBitmap = StyleGalleryItemToBmp(this.pictureBox3.Width, this.pictureBox3.Height, pStyleGalleryClass, pStyleGalleryItem); this.pictureBox3.Image = pBitmap as Image; }
private void btrChangBorderStlye_Click(object sender, EventArgs e) { Color pColor; frmLegendItemSymbol frmBackColor = new frmLegendItemSymbol(); IStyleGalleryItem pStyleGalleryItem = frmBackColor.GetItem(esriSymbologyStyleClass.esriStyleClassBackgrounds); if (pStyleGalleryItem != null) { m_SymbolBackground = (ISymbolBackground)pStyleGalleryItem.Item; pColor = this.ConvertIRgbColorToColor(((ISymbolBackground )pStyleGalleryItem.Item).FillSymbol .Color as IRgbColor); } else { m_SymbolBackground = new SymbolBackgroundClass(); pColor = Color.White; } this.btnBackGroundColor.BackColor = pColor; IStyleGalleryClass pStyleGalleryClass = new BackgroundStyleGalleryClassClass(); Bitmap pBitmap = StyleGalleryItemToBmp(this.pictureBox1.Width, this.pictureBox1.Height, pStyleGalleryClass, pStyleGalleryItem); this.pictureBox1.Image = pBitmap as Image; }
private void btnLine_Click(object sender, EventArgs e) { frmLegendItemSymbol frmAreaSymbol = new frmLegendItemSymbol(); //Get the IStyleGalleryItem that has been selected in the SymbologyControl IStyleGalleryItem styleGalleryItem = frmAreaSymbol.GetItem(esriSymbologyStyleClass.esriStyleClassLinePatches ); //change the default line(线样式) patch if (styleGalleryItem != null) plegendFormat.DefaultLinePatch = (ILinePatch)styleGalleryItem.Item; else return; }
private void btnLegendSymbol_Click(object sender, EventArgs e) { //未设置成功?????????????? frmLegendItemSymbol frmLengendSymbol = new frmLegendItemSymbol(); ESRI.ArcGIS.Controls.esriSymbologyStyleClass pStyleClass = ESRI.ArcGIS.Controls.esriSymbologyStyleClass.esriStyleClassLegendItems; IStyleGalleryItem pStyleGalleryItem= frmLengendSymbol.GetItem(pStyleClass); // pTextSymbol = frmLengendSymbol.pTextSymbol; }
private void btnChangeBCStyle_Click(object sender, EventArgs e) { Color pColor; frmLegendItemSymbol frmBolder = new frmLegendItemSymbol(); IStyleGalleryItem pStyleGalleryItem = frmBolder.GetItem(esriSymbologyStyleClass.esriStyleClassBorders); if (pStyleGalleryItem != null) { m_SymbolBorder = (ISymbolBorder)pStyleGalleryItem.Item; pColor = this.ConvertIRgbColorToColor(((ISymbolBorder )pStyleGalleryItem.Item).LineSymbol .Color as IRgbColor); } else { m_SymbolBorder = new SymbolBorderClass (); pColor = Color.White; } this.btnBolderColor .BackColor = pColor; IStyleGalleryClass pStyleGalleryClass = new BorderStyleGalleryClassClass (); Bitmap pBitmap = StyleGalleryItemToBmp(this.pictureBox2.Width, this.pictureBox2.Height, pStyleGalleryClass, pStyleGalleryItem); this.pictureBox2.Image = pBitmap as Image; }
/// <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(); }
/// <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); }
public void AddTextScale() { IGraphicsContainer graphicsContainer = m_pagelayoutControl.GraphicsContainer; //Get the MapFrame IMapFrame mapFrame = (IMapFrame)graphicsContainer.FindFrame(m_pagelayoutControl.ActiveView.FocusMap); if (mapFrame == null) return; //Create a legend UID uID = new UIDClass(); uID.Value = "esriCarto.ScaleText"; //Create a MapSurroundFrame from the MapFrame IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uID, null); if (mapSurroundFrame == null) return; if (mapSurroundFrame.MapSurround == null) return; IEnvelope m_envelop = new EnvelopeClass(); m_envelop.PutCoords(15, 15, 20, 20); frmLegendItemSymbol frmTextScal = new frmLegendItemSymbol(); IStyleGalleryItem pStyGalleryItem = frmTextScal.GetItem(esriSymbologyStyleClass.esriStyleClassScaleTexts); IScaleText pScaleText = null; if (pStyGalleryItem != null) { pScaleText = (IScaleText)pStyGalleryItem.Item; pScaleText.Map = this.m_pagelayoutControl.ActiveView.FocusMap; pScaleText.MapUnits = this.m_pagelayoutControl.ActiveView.FocusMap.MapUnits; } else return; IMapSurround m_mapSurround; m_mapSurround = (IMapSurround)pScaleText ; mapSurroundFrame.MapSurround = m_mapSurround; IElement m_element = (IElement)mapSurroundFrame; m_element.Geometry = m_envelop; m_pagelayoutControl.AddElement(m_element, Type.Missing, Type.Missing, "ScaleText", 4); m_pagelayoutControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
private void axPageLayoutControl1_OnDoubleClick(object sender, IPageLayoutControlEvents_OnDoubleClickEvent e) { if (m_element != null) { IElementProperties pElementProp = m_element as IElementProperties; if (pElementProp.Type == "Text") { ITextElement pTextElement = pElementProp as ITextElement; frmTextSymbol frmText = new frmTextSymbol(ref pTextElement); frmText.ShowDialog(); pElementProp = pTextElement as IElementProperties; m_pageLayoutControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphicSelection, null, null); m_pageLayoutControl.ActiveView.Refresh(); } else if (pElementProp.Type == "Map Surround Frame") { IMapSurroundFrame pMapSurrounFrame = pElementProp as IMapSurroundFrame; if (pMapSurrounFrame.MapSurround.Name == "Legend") { frmLegendWizard frmLegedWizard = new frmLegendWizard(m_Map, m_pageLayoutControl, pMapSurrounFrame); frmLegedWizard.ShowDialog(); //��ͼ������ } else if (pMapSurrounFrame.MapSurround.Name == "Alternating Scale Bar" || pMapSurrounFrame.MapSurround.Name == "Hollow Scale Bar" || pMapSurrounFrame.MapSurround.Name == "Double lternating Scale Bar" || pMapSurrounFrame.MapSurround.Name == "Scale Line"|| pMapSurrounFrame.MapSurround.Name == "Single Division Scale Bar" || pMapSurrounFrame.MapSurround.Name == "Stepped Scale Line") { ESRI.ArcGIS.Controls.esriSymbologyStyleClass styleClass = esriSymbologyStyleClass.esriStyleClassScaleBars; frmLegendItemSymbol frmScaleBar = new frmLegendItemSymbol(); IStyleGalleryItem pstyGallertItem = frmScaleBar.GetItem(styleClass);//��ȡ��ʽ IScaleBar pscaleBar = pMapSurrounFrame.MapSurround as IScaleBar; esriUnits punits = pscaleBar.Units; if (pstyGallertItem != null) pscaleBar = (IScaleBar)pstyGallertItem.Item; else return; pscaleBar.Map = m_pageLayoutControl.ActiveView.FocusMap; //�������ñ����������ĵ�ͼ����λ pscaleBar.Units = punits; pscaleBar.UseMapSettings(); pscaleBar.Refresh(); pMapSurrounFrame.MapSurround = pscaleBar as IMapSurround;//�ɵı�������ʽת��Ϊ�µı�������ʽ m_pageLayoutControl.Refresh(esriViewDrawPhase.esriViewGraphics, null, null);//ˢ�� } else if (pMapSurrounFrame.MapSurround.Name == "Scale Text") { frmLegendItemSymbol frmTextScal = new frmLegendItemSymbol(); IStyleGalleryItem pStyGalleryItem = frmTextScal.GetItem(esriSymbologyStyleClass.esriStyleClassScaleTexts); IScaleText pScaleText = pMapSurrounFrame.MapSurround as IScaleText; esriUnits pUnits = pScaleText.MapUnits; if (pStyGalleryItem != null) pScaleText = (IScaleText)pStyGalleryItem.Item; else return; pScaleText.Map = m_pageLayoutControl.ActiveView.FocusMap; pScaleText.MapUnits = pScaleText.MapUnits; pMapSurrounFrame.MapSurround = pScaleText as IMapSurround; m_pageLayoutControl.Refresh(esriViewDrawPhase.esriViewGraphics, null, null); } else if (pMapSurrounFrame.MapSurround.Name.Trim() == "North Arrow") { INorthArrow northArrow = pMapSurrounFrame.MapSurround as INorthArrow; frmNorthArrowSymbol frmNorthArrow = new frmNorthArrowSymbol(); IStyleGalleryItem pstyGallertItem = frmNorthArrow.GetItem(esriSymbologyStyleClass.esriStyleClassNorthArrows); ; if (pstyGallertItem != null) { northArrow = (INorthArrow)pstyGallertItem.Item; northArrow.CalibrationAngle = frmNorthArrow.Angle(); } else { return; } pMapSurrounFrame.MapSurround = (IMapSurround)northArrow; m_pageLayoutControl.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(); }
public void AddScaleBar() { IGraphicsContainer graphicsContainer = m_pagelayoutControl.GraphicsContainer; //Get the MapFrame IMapFrame mapFrame = (IMapFrame)graphicsContainer.FindFrame(m_pagelayoutControl.ActiveView.FocusMap); if (mapFrame == null) return; //Create a legend UID uID = new UIDClass(); uID.Value = "esriCarto.ScaleLine"; //Create a MapSurroundFrame from the MapFrame IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uID, null); if (mapSurroundFrame == null) return; if (mapSurroundFrame.MapSurround == null) return; // m_styleSelector = new ScaleBarSelectorClass(); IEnvelope m_envelop = new EnvelopeClass(); m_envelop.PutCoords(5, 5, 10, 10); ESRI.ArcGIS.Controls.esriSymbologyStyleClass styleClass = esriSymbologyStyleClass.esriStyleClassScaleBars; frmLegendItemSymbol frmScaleBar = new frmLegendItemSymbol(); IStyleGalleryItem pstyGallertItem = frmScaleBar.GetItem(styleClass); if (pstyGallertItem == null) { return; } IScaleBar pScalebar = pstyGallertItem.Item as IScaleBar; pScalebar.Units = m_pagelayoutControl.ActiveView.FocusMap.MapUnits; pScalebar.Map = m_pagelayoutControl.ActiveView.FocusMap; pScalebar.UseMapSettings(); IMapSurround m_mapSurround; m_mapSurround = (IMapSurround)pScalebar; mapSurroundFrame.MapSurround = m_mapSurround; IElement m_element = (IElement)mapSurroundFrame; m_element.Geometry = m_envelop; m_pagelayoutControl.AddElement(m_element, Type.Missing, Type.Missing, "ScaleLine", 3); m_pagelayoutControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }