/// <summary> /// Add the SMARTMAP text as an ITextElement to the map layout. Place the text on top /// off the black rectangle that was placed in the lower right hand corner between /// the mapframe and the neatline. /// </summary> public override void addMedfordText() { CSpatialSubs oSpatialSubs = new CSpatialSubs(); IMxDocument pMxDoc = (IMxDocument)ArcMap.Document; IGraphicsContainer pGC = (IGraphicsContainer)pMxDoc.PageLayout; try { ITextSymbol pTextSym = oSpatialSubs.createTextSymbol(255, 255, 255, (9 * base.YFactor), esriTextHorizontalAlignment.esriTHACenter, esriTextVerticalAlignment.esriTVACenter, "Arial"); string sText = "CITY OF MEDFORD"; ITextElement pTextElem = oSpatialSubs.addTextToGraphicsContainer(pGC, pTextSym, ((base.XFactor * 1.19) * SPrintConst.MapFrame_XMax), (base.XFactor * SPrintConst.MapFrame_XMax), (base.YFactor * (SPrintConst.Neatline_YMax - SPrintConst.Logo_Offset)), (base.YFactor * SPrintConst.Neatline_YMax), sText); pTextSym = null; pTextElem = null; } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Errors: CLandscapeLayout:addMedfordText()\r\n" + ex.Message, "Errors occurred", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } finally { oSpatialSubs.Dispose(); pMxDoc = null; pGC = null; } }
/// <summary> /// Add the mapscale text to the Graphic Container. Places this text under the scale bar. /// </summary> /// <param name="sMapScale"></param> public override void addMapScaleText(string sMapScale) { CSpatialSubs oSpatialSubs = new CSpatialSubs(); IMxDocument pMxDoc = (IMxDocument)this.App.Document; IGraphicsContainer pGC = (IGraphicsContainer)pMxDoc.PageLayout; IMapSurroundFrame pMSFrame = null; IEnvelope pEnv = null; ITextSymbol pTextSym = null; ITextElement pTextElem = null; try { //Locate the scalebar in the graphics container because we //want to put the mapscale right under it. //A scalebar is contained within a MapSurroundFrame. pGC.Reset(); IElement pElem = pGC.Next(); while (pElem != null) { if (pElem is IMapSurroundFrame) { pMSFrame = (IMapSurroundFrame)pElem; if (pMSFrame.Object is IScaleBar) { break; // we got the scalebar } } pElem = pGC.Next(); } pEnv = new EnvelopeClass(); //get the envelope of the scalebar pElem.QueryBounds(pMxDoc.ActiveView.ScreenDisplay, pEnv); double xMin = SPrintConst.MapscaleText_XMin * base.XFactor; double xMax = SPrintConst.MapscaleText_XMax * base.XFactor; double yMax = pEnv.YMin - 0.02; //this is the min y value of the scalebar envelope - .02 double yMin = SPrintConst.MapscaleText_YMin * base.YFactor; //Set pMapscaleText symbol to the textsymbol pTextSym = oSpatialSubs.createTextSymbol(0, 0, 0, 7 * this.YFactor, esriTextHorizontalAlignment.esriTHALeft, esriTextVerticalAlignment.esriTVATop, "Arial"); pTextElem = oSpatialSubs.addTextToGraphicsContainer(pGC, pTextSym, xMin, xMax, yMin, yMax, sMapScale); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Errors: CPortraitLayout:addMapScaleText()\r\n" + ex.Message, "Errors occurred", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } finally { oSpatialSubs.Dispose(); pMxDoc = null; pGC = null; pMSFrame = null; pEnv = null; pTextSym = null; pTextElem = null; } }
public override void addTitles(string sTitle, string sSubTitle) { CSpatialSubs oSpatialSubs = new CSpatialSubs(); IMxDocument pMxDoc = (IMxDocument)ArcMap.Document; IGraphicsContainer pGC = (IGraphicsContainer)pMxDoc.PageLayout; ITextSymbol pTitleTextSym = null; ITextElement pTitleTextElem = null; ITextSymbol pSubTitleTextSym = null; ITextElement pSubTitleTextElem = null; try { // count line breaks in sTitle int iTitleLineBreaks = sTitle.Split(new string[] { "\r\n" }, StringSplitOptions.None).Length - 1; double dblXMin = 0; double dblXMax = 0; double dblYMin = 0; double dblYMax = 0; // do the title stuff dblXMin = SPrintConst.Title_XMin * base.XFactor; //(SPrintConst.MapFrame_XMax + SPrintConst.Title_XOffset) * base.XFactor; dblXMax = SPrintConst.Title_XMax * base.XFactor; //(SPrintConst.Neatline_XMax * base.XFactor); //dblYMin = (SPrintConst.Subtitle_YMax + SPrintConst.Title_XOffset) * base.YFactor; dblYMin = SPrintConst.Title_YMin * base.YFactor; //(SPrintConst.Title_YMin * base.YFactor); dblYMax = SPrintConst.Title_YMax * base.YFactor; //SPrintConst.Title_YMax * base.YFactor; if (sTitle.Length > 0) { pTitleTextSym = oSpatialSubs.createTextSymbol(0, 0, 0, 16 * base.XFactor, esriTextHorizontalAlignment.esriTHALeft, esriTextVerticalAlignment.esriTVATop, "Arial"); pTitleTextElem = oSpatialSubs.addTextToGraphicsContainer(pGC, pTitleTextSym, dblXMin, dblXMax, dblYMin, dblYMax, sTitle); //move the title right where we want it oSpatialSubs.moveElementToXMinYmin(pTitleTextElem as IElement, dblXMin, dblYMax); } // do the subtitle stuff dblXMin = SPrintConst.Subtitle_XMin * base.XFactor; //(SPrintConst.MapFrame_XMax + SPrintConst.Title_XOffset) * base.XFactor; dblXMax = SPrintConst.Subtitle_XMax * base.XFactor; //(SPrintConst.Neatline_XMax * base.XFactor); //dblYMin = (SPrintConst.Legend_YMax + SPrintConst.Title_XOffset) * base.YFactor; dblYMin = SPrintConst.Subtitle_YMin * base.YFactor; //(SPrintConst.Title_YMin - .20) * base.YFactor; dblYMax = SPrintConst.Subtitle_YMax * base.YFactor; //SPrintConst.Subtitle_YMax * base.YFactor; if (sSubTitle.Length > 0) { if (iTitleLineBreaks > 0) { dblYMin -= (.39 * base.YFactor); } pSubTitleTextSym = oSpatialSubs.createTextSymbol(108, 108, 108, 9 * base.XFactor, esriTextHorizontalAlignment.esriTHALeft, esriTextVerticalAlignment.esriTVATop, "Arial"); pSubTitleTextElem = oSpatialSubs.addTextToGraphicsContainer(pGC, pSubTitleTextSym, dblXMin, dblXMax, dblYMin, dblYMax, sSubTitle); //move the title right where we want it oSpatialSubs.moveElementToXMinYmin(pSubTitleTextElem as IElement, dblXMin, dblYMin); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Errors: CLandscapeLayout:addTitles()\r\n" + ex.Message, "Errors occurred", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } finally { oSpatialSubs.Dispose(); pMxDoc = null; pGC = null; pTitleTextSym = null; pTitleTextElem = null; pSubTitleTextSym = null; pSubTitleTextElem = null; } }