Labels showing through the callouts

713
1
07-26-2010 01:59 PM
ericliprandi
New Contributor III
Good Afternoon,

We are upgrading our app to 10.0. We currently display some information in callouts on the map in ArcMap. We are currently seeing labels through our callouts as shown in the attached picture.
As you may be able to see, there is a red "B" letter just by the the word. This is showing through the text box.
The code to display that is pretty simple and is posted below. We did not notice this issue with versions prior to 10.0. Just trying to identify if this is user error, new "feature" or other.

Thanks,

Eric.
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.ArcMapUI;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Desktop.AddIns;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Geometry;
using Point = ESRI.ArcGIS.Geometry.Point;

namespace ArcMapLabelsIssue
{
 public class EricTest : Button
 {
  protected override void OnClick()
  {
   //
   //  TODO: Sample code showing how to access button host
   //
   ArcMap.Application.CurrentTool = null;

   var doc = (IMxDocument) ArcMap.Application.Document;
   var view = (IActiveView) doc.FocusMap;
   var center = new Point {X = (view.Extent.XMin + view.Extent.XMax)/2, Y = (view.Extent.YMin + view.Extent.YMax)/2};
   IElement element = GetElement(center);
   element.Activate(view.ScreenDisplay);

   IGraphicsContainer container = GetGraphicsContainer();
   container.AddElement(element, 0);

   view.Refresh();
   view.ScreenDisplay.UpdateWindow();
  }

  protected override void OnUpdate()
  {
   Enabled = ArcMap.Application != null;
  }

  private IElement GetElement(IPoint origin)
  {
   const string text = "This is what I want to see in the box";
   var myColor = new RgbColorClass
                  {
                   Red = Color.LightYellow.R,
                   Green = Color.LightYellow.G,
                   Blue = Color.LightYellow.B
                  };

   const double textSize = 8.0d;
   const string fontName = "Arial";

   var textElement = new TextElementClass
                      {
                       Text = text,
                       HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft
                      };

   IPoint point = origin;

   //Set the location of the balloon callout
   IPoint textElementPoint = new PointClass();
   textElementPoint.PutCoords(origin.X, origin.Y);
   //   textElementPoint.Project(_map.SpatialReference);
   textElement.Geometry = textElementPoint;
   //Mark the element with a custom property
   ISimpleFillSymbol smplFill = new SimpleFillSymbolClass
                                 {
                                  Color = myColor,
                                  Style = esriSimpleFillStyle.esriSFSSolid
                                 };
   var blnCallout = new BalloonCalloutClass
                     {
                      Style = esriBalloonCalloutStyle.esriBCSRoundedRectangle,
                      Symbol = smplFill
                     };

   //Set the text element symbology to a default balloon callout
   var textSymbol = new TextSymbolClass
                     {
                      Background = blnCallout,
                      HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft,
                      VerticalAlignment = esriTextVerticalAlignment.esriTVATop
                     };


   //Set the location of the callout anchor
   IPoint anchorPoint = point;
   anchorPoint.Y = origin.Y;
   anchorPoint.X = origin.X;
   blnCallout.AnchorPoint = anchorPoint;
   textElement.Symbol = textSymbol;
   //Custom Property will store true for region text and false for ballons
   textElement.CustomProperty = false;
   textElement.Size = textSize;
   textElement.FontName = fontName;
   textElement.AnchorPoint = esriAnchorPointEnum.esriCenterPoint;

   textElement.ScaleText = true;
   return textElement;
  }

  private IGraphicsContainer GetGraphicsContainer()
  {
   var document = ArcMap.Application.Document as IMxDocument;
   if (document == null) return null;
   IMap map = document.FocusMap;
   double? referenceScale;
   try
   {
    referenceScale = map.MapScale;
   }
   catch (Exception)
   {
    return null;
   }
   var compositeGraphicsLayer = map.BasicGraphicsLayer as ICompositeGraphicsLayer;
   if (compositeGraphicsLayer == null) return null;
   IGraphicsLayer graphicsLayer;
   try
   {
    graphicsLayer = compositeGraphicsLayer.FindLayer("Telvent007");
   }
   catch (COMException)
   {
    //When layer doesn't exist, it fires a COMException.
    graphicsLayer = null;
   }
   //Graphical layer doesn't exist. We create one.
   if (graphicsLayer == null)
   {
    //In case there were any displayed element, context should be deleted.
    graphicsLayer = compositeGraphicsLayer.AddLayer("Telvent007", null);
    var layer = graphicsLayer as ILayer;
    if (layer == null) return null;
    map.ActiveGraphicsLayer = layer;
   }
   var scale = graphicsLayer as IGraphicsLayerScale;
   if (scale == null) return null;
   scale.ReferenceScale = (double) referenceScale;
   return graphicsLayer as IGraphicsContainer;
  }
 }
}
0 Kudos
1 Reply
PatrickBurke
New Contributor II
Did you ever solve this problem?  I am having the same issue.  How can this be fixed?  Thanks.
0 Kudos