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); }
private void mi_AddNorthArrow_Click(object sender, EventArgs e) { IActiveView pActiveView = axPageLayoutControl1.PageLayout as IActiveView; IMap pMap = pActiveView.FocusMap as IMap; IGraphicsContainer pGraphicsContainer = pActiveView as IGraphicsContainer; IMapFrame pMapFrame = pGraphicsContainer.FindFrame(pMap) as IMapFrame; IMapSurround pMapSurround; INorthArrow pNorthArrow; pNorthArrow = new MarkerNorthArrowClass(); pMapSurround = pNorthArrow; pMapSurround.Name = "NorthArrow"; //定义UID UID uid = new UIDClass(); uid.Value = "esriCarto.MarkerNorthArrow"; //定义MapSurroundFrame对象 IMapSurroundFrame pMapSurroundFrame = pMapFrame.CreateSurroundFrame(uid, null); pMapSurroundFrame.MapSurround = pMapSurround; //定义Envelope设置Element摆放的位置 IEnvelope pEnvelope = new EnvelopeClass(); pEnvelope.PutCoords(17, 25, 17, 25); IElement pElement = pMapSurroundFrame as IElement; pElement.Geometry = pEnvelope; pGraphicsContainer.AddElement(pElement, 0); }
// 添加指北针 public static void AddNorthArrow(AxPageLayoutControl pageLayoutControl, IEnvelope envelope) { IMap pMap = pageLayoutControl.ActiveView.FocusMap; IGraphicsContainer pGraphicsContariner = pageLayoutControl.PageLayout as IGraphicsContainer; IMapFrame pMapFrame = pGraphicsContariner.FindFrame(pMap) as IMapFrame; IMapSurroundFrame pMapSurroundFrame = new MapSurroundFrameClass() { MapFrame = pMapFrame }; INorthArrow pNorthArrow = new MarkerNorthArrowClass() { //MarkerSymbol = new MarkerSym }; }
private void 添加指北针ToolStripMenuItem_Click(object sender, EventArgs e) { IActiveView pActiveView = axPageLayoutControl1.PageLayout as IActiveView; IMap pMap = pActiveView.FocusMap as IMap; IGraphicsContainer pGraphicsContainer = pActiveView as IGraphicsContainer; IMapFrame pMapFrame = pGraphicsContainer.FindFrame(pMap) as IMapFrame; IMapSurround pMapSurround; INorthArrow pNorthArrow; pNorthArrow = new MarkerNorthArrowClass(); pMapSurround = pNorthArrow; pMapSurround.Name = "NorthArrow"; //定义UID UID uid = new UIDClass(); uid.Value = "esriCarto.MarkerNorthArrow"; //定义MapSurroundFrame对象 IMapSurroundFrame pMapSurroundFrame = pMapFrame.CreateSurroundFrame(uid, null); pMapSurroundFrame.MapSurround = pMapSurround; IElement pDeletElement = axPageLayoutControl1.FindElementByName("NorthArrow");//获取PageLayout中的图例元素 if (pDeletElement != null) { pGraphicsContainer.DeleteElement(pDeletElement); //如果已经存在指北针,删除已经存在的指北针 } //定义Envelope设置Element摆放的位置 IEnvelope pEnvelope = new EnvelopeClass(); pEnvelope.PutCoords(16, 24, 21, 32); IElement pElement = pMapSurroundFrame as IElement; pElement.Geometry = pEnvelope; pGraphicsContainer.AddElement(pElement, 0); //刷新axPageLayoutControl1的内容 axPageLayoutControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
public override IElement CreateElement(IPageLayout ipageLayout_0) { INorthArrow optionalStyle = new MarkerNorthArrowClass(); (optionalStyle as IMarkerNorthArrow).MarkerSymbol = (base.Style as IMarkerNorthArrow).MarkerSymbol; IEnvelope oldBounds = new EnvelopeClass(); IPoint position = this.GetPosition(ipageLayout_0); oldBounds.PutCoords(position.X, position.Y, position.X + 3.0, position.Y + 3.0); UID clsid = new UIDClass { Value = "esriCarto.MarkerNorthArrow" }; IMapFrame frame = (ipageLayout_0 as IGraphicsContainer).FindFrame((ipageLayout_0 as IActiveView).FocusMap) as IMapFrame; IElement element = frame.CreateSurroundFrame(clsid, optionalStyle) as IElement; IEnvelope newBounds = new EnvelopeClass(); optionalStyle.QueryBounds((ipageLayout_0 as IActiveView).ScreenDisplay, oldBounds, newBounds); oldBounds.PutCoords(position.X, position.Y, position.X + newBounds.Width, position.Y + newBounds.Height); element.Geometry = oldBounds; this.Element = element; return(element); }
private void button_dress_Click(object sender, EventArgs e) { //获取axPageLayoutControl1的图形容器 IGraphicsContainer graphicsContainer = axPageLayoutControl1.GraphicsContainer; //获取axPageLayoutControl1空间里面显示的地图图层 IMapFrame mapFrame = (IMapFrame)graphicsContainer.FindFrame(axPageLayoutControl1.ActiveView.FocusMap); if (mapFrame == null) { return; } //--------------创建图例------------ UID uID = new UIDClass(); //创建UID作为该图例的唯一标识符,方便创建之后进行删除、移动等操作 uID.Value = "esriCarto.Legend"; IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uID, null); if (mapSurroundFrame == null) { return; } if (mapSurroundFrame.MapSurround == null) { return; } mapSurroundFrame.MapSurround.Name = "图例"; IEnvelope envelope = new EnvelopeClass(); envelope.PutCoords(16, 2, 18, 7);//设置图例摆放位置(原点在axPageLayoutControl左下角) IElement element = (IElement)mapSurroundFrame; element.Geometry = envelope; //将图例转化为几何要素添加到axPageLayoutControl1,并刷新页面显示 axPageLayoutControl1.AddElement(element, Type.Missing, Type.Missing, "Legend", 0); axPageLayoutControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); //-----------设置指北针-------- IMapSurround pMapSurround; INorthArrow pNorthArrow; pNorthArrow = new MarkerNorthArrowClass();//创建指北针的实例 pMapSurround = pNorthArrow; pMapSurround.Name = "NorthArrow"; //定义UID UID uid = new UIDClass(); uid.Value = "esriCarto.MarkerNorthArrow"; //定义MapSurroundFrame对象 IMapSurroundFrame pMapSurroundFrame = mapFrame.CreateSurroundFrame(uid, null); pMapSurroundFrame.MapSurround = pMapSurround; IElement pDeletElement = axPageLayoutControl1.FindElementByName("NorthArrow");//获取PageLayout中的图例元素 if (pDeletElement != null) { graphicsContainer.DeleteElement(pDeletElement); //如果已经存在指北针,删除已经存在的指北针 } //定义Envelope设置Element摆放的位置 IEnvelope pEnvelope = new EnvelopeClass(); pEnvelope.PutCoords(16, 24, 21, 32); IElement pElement = pMapSurroundFrame as IElement; pElement.Geometry = pEnvelope; graphicsContainer.AddElement(pElement, 0); //刷新axPageLayoutControl1的内容 axPageLayoutControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); //-----------设置比例尺------------ IActiveView pActiveView = axPageLayoutControl1.PageLayout as IActiveView; IMap pMap = pActiveView.FocusMap as IMap; IGraphicsContainer pGraphicsContainer = pActiveView as IGraphicsContainer; IMapFrame pMapFrame = pGraphicsContainer.FindFrame(pMap) as IMapFrame; //IMapSurround pMapSurround; //设置比例尺样式 IScaleBar pScaleBar = new ScaleLineClass(); pScaleBar.Units = esriUnits.esriKilometers; pScaleBar.Divisions = 4; pScaleBar.Subdivisions = 3; pScaleBar.DivisionsBeforeZero = 0; pScaleBar.UnitLabel = "km"; pScaleBar.LabelPosition = esriVertPosEnum.esriBelow; pScaleBar.LabelGap = 3.6; pScaleBar.LabelFrequency = esriScaleBarFrequency.esriScaleBarDivisionsAndFirstMidpoint; pScaleBar.LabelPosition = esriVertPosEnum.esriBelow; ITextSymbol pTextsymbol = new TextSymbolClass(); pTextsymbol.Size = 1; stdole.StdFont pFont = new stdole.StdFont(); pFont.Size = 3; pFont.Name = "Arial"; pTextsymbol.Font = pFont as stdole.IFontDisp; pTextsymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; pScaleBar.UnitLabelSymbol = pTextsymbol; pScaleBar.LabelSymbol = pTextsymbol; INumericFormat pNumericFormat = new NumericFormatClass(); pNumericFormat.AlignmentWidth = 0; pNumericFormat.RoundingOption = esriRoundingOptionEnum.esriRoundNumberOfSignificantDigits; pNumericFormat.RoundingValue = 0; pNumericFormat.UseSeparator = true; pNumericFormat.ShowPlusSign = false; //定义UID pMapSurround = pScaleBar; pMapSurround.Name = "ScaleBar"; // UID uid = new UIDClass(); uid.Value = "esriCarto.ScaleLine"; //定义MapSurroundFrame对象IMapSurroundFrame pMapSurroundFrame = pMapFrame.CreateSurroundFrame(uid, null); pMapSurroundFrame.MapSurround = pMapSurround; //定义Envelope设置Element摆放的位置 //IEnvelope pEnvelope = new EnvelopeClass(); pEnvelope.PutCoords(8, 2, 14, 4); //IElement pElement = pMapSurroundFrame as IElement; pElement.Geometry = pEnvelope; //IElement pDeletElement = axPageLayoutControl1.FindElementByName("ScaleBar"); //获取PageLayout中的比例尺元素 if (pDeletElement != null) { pGraphicsContainer.DeleteElement(pDeletElement); //如果已经存在比例尺,删除已经存在的比例尺 } pGraphicsContainer.AddElement(pElement, 0); //刷新axPageLayoutControl1的内容 axPageLayoutControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); //---------------添加标题------------- //IGraphicsContainer graphicsContainer = axPageStation.PageLayout as IGraphicsContainer; //IEnvelope envelope = new EnvelopeClass(); envelope.PutCoords(-14, 26, 35, 26); IRgbColor pColor = new RgbColorClass() { Red = 0, Blue = 0, Green = 0 }; pFont.Name = "宋体"; pFont.Bold = true; ITextSymbol pTextSymbol = new TextSymbolClass() { Color = pColor, //Font = pFont, Size = 30 }; ITextElement pTextElement = new TextElementClass() { Symbol = pTextSymbol, ScaleText = true, Text = "盗墓难度专题图" }; element = pTextElement as ESRI.ArcGIS.Carto.IElement; element.Geometry = envelope; graphicsContainer.AddElement(element, 0); axPageLayoutControl1.Refresh(); }
public static IElement CreateElement(IPageLayout ipageLayout_0) { int num; double num1; double num2; ITextSymbol symbol; esriTextHorizontalAlignment horizontalAlignment; esriTextVerticalAlignment verticalAlignment; IScaleText scaleTextClass; UID uIDClass; IMapFrame mapFrame; IEnvelope envelopeClass; IEnvelope envelope; ILegend legendClass2; IScaleBar hollowScaleBarClass; double num3; double num4; INorthArrow markerNorthArrowClass; IPoint position = ElementWizardHelp.GetPosition(ipageLayout_0, out num, out num1, out num2); IElement textElementClass = null; switch (ElementWizardHelp.m_ElementType) { case ElementType.ConstantText: { textElementClass = new TextElementClass(); (textElementClass as IElementProperties).Name = ElementWizardHelp.m_Text; (textElementClass as ITextElement).Text = ElementWizardHelp.m_Text; if (ElementWizardHelp.m_pStyle != null) { ElementWizardHelp.SetTextSymblAlign(ElementWizardHelp.m_pStyle as ITextSymbol, num); (textElementClass as ITextElement).Symbol = ElementWizardHelp.m_pStyle as ITextSymbol; } textElementClass.Geometry = position; if (!ElementWizardHelp.m_IsVerticalText) { (textElementClass as IElementProperties).Type = ""; symbol = (textElementClass as ITextElement).Symbol; if (symbol.Angle != 270) { return(textElementClass); } (symbol as ICharacterOrientation).CJKCharactersRotation = false; symbol.Angle = 0; horizontalAlignment = symbol.HorizontalAlignment; verticalAlignment = symbol.VerticalAlignment; if (horizontalAlignment == esriTextHorizontalAlignment.esriTHALeft) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom; } else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHAFull) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom; } else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHARight) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop; } else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHACenter) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter; } if (verticalAlignment == esriTextVerticalAlignment.esriTVATop) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; } else if (verticalAlignment == esriTextVerticalAlignment.esriTVABottom) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight; } else if (verticalAlignment == esriTextVerticalAlignment.esriTVACenter) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter; } else if (verticalAlignment == esriTextVerticalAlignment.esriTVABaseline) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight; } (textElementClass as ITextElement).Symbol = symbol; return(textElementClass); } else { (textElementClass as IElementProperties).Type = "竖向"; symbol = (textElementClass as ITextElement).Symbol; (symbol as ICharacterOrientation).CJKCharactersRotation = true; symbol.Angle = 270; horizontalAlignment = symbol.HorizontalAlignment; verticalAlignment = symbol.VerticalAlignment; if (horizontalAlignment == esriTextHorizontalAlignment.esriTHALeft) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop; } else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHAFull) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop; } else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHARight) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom; } else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHACenter) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter; } if (verticalAlignment == esriTextVerticalAlignment.esriTVATop) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; } else if (verticalAlignment == esriTextVerticalAlignment.esriTVABottom) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight; } else if (verticalAlignment == esriTextVerticalAlignment.esriTVACenter) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter; } else if (verticalAlignment == esriTextVerticalAlignment.esriTVABaseline) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight; } (textElementClass as ITextElement).Symbol = symbol; return(textElementClass); } } case ElementType.SingleText: { textElementClass = new TextElementClass(); (textElementClass as IElementProperties).Name = ElementWizardHelp.m_Text; (textElementClass as ITextElement).Text = string.Concat("=", ElementWizardHelp.m_Text); if (ElementWizardHelp.m_pStyle != null) { ElementWizardHelp.SetTextSymblAlign(ElementWizardHelp.m_pStyle as ITextSymbol, num); (textElementClass as ITextElement).Symbol = ElementWizardHelp.m_pStyle as ITextSymbol; } textElementClass.Geometry = position; if (!ElementWizardHelp.m_IsVerticalText) { (textElementClass as IElementProperties).Type = ""; symbol = (textElementClass as ITextElement).Symbol; if (symbol.Angle != 270) { return(textElementClass); } (symbol as ICharacterOrientation).CJKCharactersRotation = false; symbol.Angle = 0; horizontalAlignment = symbol.HorizontalAlignment; verticalAlignment = symbol.VerticalAlignment; if (horizontalAlignment == esriTextHorizontalAlignment.esriTHALeft) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom; } else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHAFull) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom; } else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHARight) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop; } else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHACenter) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter; } if (verticalAlignment == esriTextVerticalAlignment.esriTVATop) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; } else if (verticalAlignment == esriTextVerticalAlignment.esriTVABottom) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight; } else if (verticalAlignment == esriTextVerticalAlignment.esriTVACenter) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter; } else if (verticalAlignment == esriTextVerticalAlignment.esriTVABaseline) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight; } (textElementClass as ITextElement).Symbol = symbol; return(textElementClass); } else { (textElementClass as IElementProperties).Type = "竖向"; symbol = (textElementClass as ITextElement).Symbol; (symbol as ICharacterOrientation).CJKCharactersRotation = true; symbol.Angle = 270; horizontalAlignment = symbol.HorizontalAlignment; verticalAlignment = symbol.VerticalAlignment; if (horizontalAlignment == esriTextHorizontalAlignment.esriTHALeft) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom; } else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHAFull) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom; } else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHARight) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop; } else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHACenter) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter; } if (verticalAlignment == esriTextVerticalAlignment.esriTVATop) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; } else if (verticalAlignment == esriTextVerticalAlignment.esriTVABottom) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight; } else if (verticalAlignment == esriTextVerticalAlignment.esriTVACenter) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter; } else if (verticalAlignment == esriTextVerticalAlignment.esriTVABaseline) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight; } (textElementClass as ITextElement).Symbol = symbol; return(textElementClass); } } case ElementType.MultiText: { textElementClass = new TextElementClass(); (textElementClass as IElementProperties).Name = ElementWizardHelp.m_Text; (textElementClass as ITextElement).Text = string.Concat("M=", ElementWizardHelp.m_Text); if (ElementWizardHelp.m_pStyle != null) { ElementWizardHelp.SetTextSymblAlign(ElementWizardHelp.m_pStyle as ITextSymbol, num); (textElementClass as ITextElement).Symbol = ElementWizardHelp.m_pStyle as ITextSymbol; } textElementClass.Geometry = position; if (!ElementWizardHelp.m_IsVerticalText) { (textElementClass as IElementProperties).Type = ""; symbol = (textElementClass as ITextElement).Symbol; if (symbol.Angle != 270) { return(textElementClass); } (symbol as ICharacterOrientation).CJKCharactersRotation = false; symbol.Angle = 0; horizontalAlignment = symbol.HorizontalAlignment; verticalAlignment = symbol.VerticalAlignment; if (horizontalAlignment == esriTextHorizontalAlignment.esriTHALeft) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom; } else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHAFull) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom; } else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHARight) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop; } else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHACenter) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter; } if (verticalAlignment == esriTextVerticalAlignment.esriTVATop) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; } else if (verticalAlignment == esriTextVerticalAlignment.esriTVABottom) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight; } else if (verticalAlignment == esriTextVerticalAlignment.esriTVACenter) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter; } else if (verticalAlignment == esriTextVerticalAlignment.esriTVABaseline) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight; } (textElementClass as ITextElement).Symbol = symbol; return(textElementClass); } else { (textElementClass as IElementProperties).Type = "竖向"; symbol = (textElementClass as ITextElement).Symbol; (symbol as ICharacterOrientation).CJKCharactersRotation = true; symbol.Angle = 270; horizontalAlignment = symbol.HorizontalAlignment; verticalAlignment = symbol.VerticalAlignment; if (horizontalAlignment == esriTextHorizontalAlignment.esriTHALeft) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop; } else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHAFull) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop; } else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHARight) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom; } else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHACenter) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter; } if (verticalAlignment == esriTextVerticalAlignment.esriTVATop) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; } else if (verticalAlignment == esriTextVerticalAlignment.esriTVABottom) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight; } else if (verticalAlignment == esriTextVerticalAlignment.esriTVACenter) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter; } else if (verticalAlignment == esriTextVerticalAlignment.esriTVABaseline) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight; } (textElementClass as ITextElement).Symbol = symbol; return(textElementClass); } } case ElementType.JoinTable: { textElementClass = (new JionTab()).CreateJionTab(ipageLayout_0 as IActiveView, position); return(textElementClass); } case ElementType.ScaleText: { if (ElementWizardHelp.m_pStyle == null) { scaleTextClass = new ScaleTextClass(); } else { scaleTextClass = ElementWizardHelp.m_pStyle as IScaleText; } uIDClass = new UIDClass() { Value = "esriCarto.ScaleText" }; mapFrame = (ipageLayout_0 as IGraphicsContainer).FindFrame((ipageLayout_0 as IActiveView).FocusMap) as IMapFrame; scaleTextClass.MapUnits = mapFrame.Map.DistanceUnits; scaleTextClass.PageUnits = ipageLayout_0.Page.Units; scaleTextClass.Style = esriScaleTextStyleEnum.esriScaleTextAbsolute; INumberFormat numberFormat = scaleTextClass.NumberFormat; if (numberFormat is INumericFormat) { (numberFormat as INumericFormat).RoundingOption = esriRoundingOptionEnum.esriRoundNumberOfDecimals; (numberFormat as INumericFormat).UseSeparator = false; (numberFormat as INumericFormat).RoundingValue = 0; scaleTextClass.NumberFormat = numberFormat; } textElementClass = mapFrame.CreateSurroundFrame(uIDClass, scaleTextClass) as IElement; envelopeClass = new EnvelopeClass(); envelopeClass.PutCoords(position.X, position.Y, position.X + 4, position.Y + 8); envelope = new EnvelopeClass(); scaleTextClass.QueryBounds((ipageLayout_0 as IActiveView).ScreenDisplay, envelopeClass, envelope); envelopeClass.PutCoords(position.X, position.Y, position.X + envelope.Width, position.Y + envelope.Height); textElementClass.Geometry = envelopeClass; return(textElementClass); } case ElementType.CustomLegend: { CustomLegend customLegend = new CustomLegend() { LegendInfo = ElementWizardHelp.m_pLegendInfo }; customLegend.Init(ipageLayout_0 as IActiveView, position); textElementClass = customLegend; return(textElementClass); } case ElementType.Legend: { if (ElementWizardHelp.m_pStyle == null) { legendClass2 = new LegendClass_2(); } else { legendClass2 = ElementWizardHelp.m_pStyle as ILegend; } legendClass2.AutoAdd = true; legendClass2.AutoReorder = true; legendClass2.AutoVisibility = true; uIDClass = new UIDClass() { Value = "esriCarto.Legend" }; mapFrame = (ipageLayout_0 as IGraphicsContainer).FindFrame((ipageLayout_0 as IActiveView).FocusMap) as IMapFrame; textElementClass = mapFrame.CreateSurroundFrame(uIDClass, legendClass2) as IElement; envelopeClass = new EnvelopeClass(); envelopeClass.PutCoords(position.X, position.Y, position.X + 4, position.Y + 8); envelope = new EnvelopeClass(); legendClass2.QueryBounds((ipageLayout_0 as IActiveView).ScreenDisplay, envelopeClass, envelope); envelopeClass.PutCoords(position.X, position.Y, position.X + envelope.Width, position.Y + envelope.Height); textElementClass.Geometry = envelopeClass; return(textElementClass); } case ElementType.Picture: { string lower = System.IO.Path.GetExtension(ElementWizardHelp.m_PictureFileName).ToLower(); textElementClass = null; string str = lower; if (string.IsNullOrEmpty(str)) { textElementClass = new PngPictureElementClass(); (textElementClass as IPictureElement).ImportPictureFromFile(ElementWizardHelp.m_PictureFileName); (textElementClass as IPictureElement).MaintainAspectRatio = true; num3 = 0; num4 = 0; (textElementClass as IPictureElement2).QueryIntrinsicSize(ref num3, ref num4); num3 = num3 * 0.0353; num4 = num4 * 0.0353; (textElementClass as IElementProperties2).AutoTransform = true; envelopeClass = new EnvelopeClass(); envelopeClass.PutCoords(position.X, position.Y, position.X + num3, position.Y + num4); textElementClass.Geometry = envelopeClass; return(textElementClass); } else if (str == ".bmp") { textElementClass = new BmpPictureElementClass(); } else if (str == ".jpg") { textElementClass = new JpgPictureElementClass(); } else if (str == ".gif") { textElementClass = new GifPictureElementClass(); } else if (str == ".tif") { textElementClass = new TifPictureElementClass(); } else { if (str != ".emf") { textElementClass = new PngPictureElementClass(); (textElementClass as IPictureElement).ImportPictureFromFile(ElementWizardHelp.m_PictureFileName); (textElementClass as IPictureElement).MaintainAspectRatio = true; num3 = 0; num4 = 0; (textElementClass as IPictureElement2).QueryIntrinsicSize(ref num3, ref num4); num3 = num3 * 0.0353; num4 = num4 * 0.0353; (textElementClass as IElementProperties2).AutoTransform = true; envelopeClass = new EnvelopeClass(); envelopeClass.PutCoords(position.X, position.Y, position.X + num3, position.Y + num4); textElementClass.Geometry = envelopeClass; return(textElementClass); } textElementClass = new EmfPictureElementClass(); } (textElementClass as IPictureElement).ImportPictureFromFile(ElementWizardHelp.m_PictureFileName); (textElementClass as IPictureElement).MaintainAspectRatio = true; num3 = 0; num4 = 0; (textElementClass as IPictureElement2).QueryIntrinsicSize(ref num3, ref num4); num3 = num3 * 0.0353; num4 = num4 * 0.0353; (textElementClass as IElementProperties2).AutoTransform = true; envelopeClass = new EnvelopeClass(); envelopeClass.PutCoords(position.X, position.Y, position.X + num3, position.Y + num4); textElementClass.Geometry = envelopeClass; return(textElementClass); } case ElementType.OLE: { int screenDisplay = (ipageLayout_0 as IActiveView).ScreenDisplay.hWnd; Common.ExtendClass.IOleFrame oleFrame = new OleFrame(); if (!oleFrame.CreateOleClientItem((ipageLayout_0 as IActiveView).ScreenDisplay, screenDisplay)) { return(textElementClass); } textElementClass = oleFrame as IElement; envelopeClass = new EnvelopeClass(); envelopeClass.PutCoords(position.X, position.Y, position.X + 4, position.Y + 8); envelope = new EnvelopeClass(); textElementClass.QueryBounds((ipageLayout_0 as IActiveView).ScreenDisplay, envelope); envelopeClass.PutCoords(position.X, position.Y, position.X + envelope.Width, position.Y + envelope.Height); textElementClass.Geometry = envelopeClass; return(textElementClass); } case ElementType.ScaleBar: { if (ElementWizardHelp.m_pStyle == null) { hollowScaleBarClass = new HollowScaleBarClass(); } else { hollowScaleBarClass = ElementWizardHelp.m_pStyle as IScaleBar; } uIDClass = new UIDClass() { Value = "esriCarto.ScaleBar" }; mapFrame = (ipageLayout_0 as IGraphicsContainer).FindFrame((ipageLayout_0 as IActiveView).FocusMap) as IMapFrame; hollowScaleBarClass.Units = mapFrame.Map.DistanceUnits; textElementClass = mapFrame.CreateSurroundFrame(uIDClass, hollowScaleBarClass) as IElement; envelopeClass = new EnvelopeClass(); envelopeClass.PutCoords(position.X, position.Y, position.X + 4, position.Y + 8); envelope = new EnvelopeClass(); hollowScaleBarClass.QueryBounds((ipageLayout_0 as IActiveView).ScreenDisplay, envelopeClass, envelope); envelopeClass.PutCoords(position.X, position.Y, position.X + envelope.Width, position.Y + envelope.Height); textElementClass.Geometry = envelopeClass; return(textElementClass); } case ElementType.North: { if (ElementWizardHelp.m_pStyle == null) { markerNorthArrowClass = new MarkerNorthArrowClass(); } else { markerNorthArrowClass = ElementWizardHelp.m_pStyle as INorthArrow; } envelopeClass = new EnvelopeClass(); envelopeClass.PutCoords(position.X, position.Y, position.X + 3, position.Y + 3); uIDClass = new UIDClass() { Value = "esriCarto.MarkerNorthArrow" }; mapFrame = (ipageLayout_0 as IGraphicsContainer).FindFrame((ipageLayout_0 as IActiveView).FocusMap) as IMapFrame; textElementClass = mapFrame.CreateSurroundFrame(uIDClass, markerNorthArrowClass) as IElement; envelope = new EnvelopeClass(); markerNorthArrowClass.QueryBounds((ipageLayout_0 as IActiveView).ScreenDisplay, envelopeClass, envelope); envelopeClass.PutCoords(position.X, position.Y, position.X + envelope.Width, position.Y + envelope.Height); textElementClass.Geometry = envelopeClass; return(textElementClass); } case ElementType.GraphicElement: { return(textElementClass); } case ElementType.DataGraphicElement: { envelopeClass = new EnvelopeClass(); envelopeClass.PutCoords(position.X, position.Y, position.X + 8, position.Y + 8); textElementClass = new DataGraphicsElement() { Geometry = envelopeClass }; return(textElementClass); } default: { return(textElementClass); } } }
private void frmSymbolProperty_Load(object sender, EventArgs e) { if (this.m_pStyleGalleryItem != null) { this.txtName.Text = this.m_pStyleGalleryItem.Name; this.txtCategory.Text = this.m_pStyleGalleryItem.Category; this.symbolItem1.Symbol = this.m_pStyleGalleryItem.Item; if (this.symbolItem1.Symbol is IMarkerSymbol) { this.m_SymbolType = enumSymbolType.enumSTPoint; } else if (this.symbolItem1.Symbol is ILineSymbol) { this.m_SymbolType = enumSymbolType.enumSTLine; } else if (this.symbolItem1.Symbol is IFillSymbol) { this.m_SymbolType = enumSymbolType.enumSTFill; } else if (this.symbolItem1.Symbol is ITextSymbol) { this.m_SymbolType = enumSymbolType.enumSTText; } else if (this.symbolItem1.Symbol is IColorRamp) { this.m_SymbolType = enumSymbolType.enumSTColorRamp; } else if (this.symbolItem1.Symbol is IColor) { this.m_SymbolType = enumSymbolType.enumSTColor; } else if (this.symbolItem1.Symbol is ISymbolBorder) { this.m_SymbolType = enumSymbolType.enumSTBorder; } else if (this.symbolItem1.Symbol is ISymbolBackground) { this.m_SymbolType = enumSymbolType.enumSTBackground; } else if (this.symbolItem1.Symbol is ISymbolShadow) { this.m_SymbolType = enumSymbolType.enumSTShadow; } else if (this.symbolItem1.Symbol is IMarkerNorthArrow) { this.m_SymbolType = enumSymbolType.enumSTNorthArrow; } else if (this.symbolItem1.Symbol is IScaleBar) { this.m_SymbolType = enumSymbolType.enumSTScaleBar; } else if (this.symbolItem1.Symbol is IScaleText) { this.m_SymbolType = enumSymbolType.enumSTScaleText; } else if (this.symbolItem1.Symbol is ILegendItem) { this.m_SymbolType = enumSymbolType.enumSTLegendItem; } else { this.m_SymbolType = enumSymbolType.enumSTUnknown; } } else { this.m_pStyleGalleryItem = new ServerStyleGalleryItemClass(); object obj2 = null; switch (this.m_SymbolType) { case enumSymbolType.enumSTPoint: this.txtName.Text = "点符号"; obj2 = new MultiLayerMarkerSymbolClass(); ((IMultiLayerMarkerSymbol)obj2).AddLayer(new SimpleMarkerSymbolClass()); break; case enumSymbolType.enumSTLine: this.txtName.Text = "线符号"; obj2 = new MultiLayerLineSymbolClass(); ((IMultiLayerLineSymbol)obj2).AddLayer(new SimpleLineSymbolClass()); break; case enumSymbolType.enumSTFill: this.txtName.Text = "面符号"; obj2 = new MultiLayerFillSymbolClass(); ((IMultiLayerFillSymbol)obj2).AddLayer(new SimpleFillSymbolClass()); break; case enumSymbolType.enumSTText: case enumSymbolType.enumSTColorRamp: case enumSymbolType.enumSTColor: case enumSymbolType.enumSTLinePatch: case enumSymbolType.enumSTAreaPatch: return; case enumSymbolType.enumSTNorthArrow: this.txtName.Text = "指北针"; obj2 = new MarkerNorthArrowClass(); break; case enumSymbolType.enumSTScaleBar: this.txtName.Text = "比例尺"; obj2 = new ScaleLineClass(); break; case enumSymbolType.enumSTScaleText: this.txtName.Text = "比例尺文本"; obj2 = new ScaleTextClass(); break; case enumSymbolType.enumSTBorder: this.txtName.Text = "边界"; obj2 = new SymbolBorderClass(); break; case enumSymbolType.enumSTShadow: this.txtName.Text = "阴影"; obj2 = new SymbolShadowClass(); break; case enumSymbolType.enumSTBackground: this.txtName.Text = "背景"; obj2 = new SymbolBackgroundClass(); break; case enumSymbolType.enumSTLegendItem: this.txtName.Text = "图例项"; obj2 = new HorizontalLegendItemClass(); break; case enumSymbolType.enumSTLabel: this.txtName.Text = "标注"; obj2 = new LabelStyleClass(); break; default: return; } this.symbolItem1.Symbol = obj2; this.m_pStyleGalleryItem.Name = this.txtName.Text; this.m_pStyleGalleryItem.Category = this.txtCategory.Text; this.m_pStyleGalleryItem.Item = obj2; } }