Example #1
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (this.mapGridBorderPropertyPage_0.OutlineSymbol != null)
     {
         IElement    element = new RectangleElementClass();
         IFillSymbol symbol  = new SimpleFillSymbolClass
         {
             Outline = this.mapGridBorderPropertyPage_0.OutlineSymbol
         };
         (symbol as ISimpleFillSymbol).Style   = esriSimpleFillStyle.esriSFSNull;
         (element as IFillShapeElement).Symbol = symbol;
         IEnvelope envelope = (this.imapFrame_0 as IElement).Geometry.Envelope;
         envelope.Expand(1.0, 1.0, false);
         element.Geometry = envelope;
         IFrameElement element2 = new FrameElementClass();
         (element2 as IElement).Geometry = envelope;
         IGroupElement group = new GroupElementClass();
         this.igraphicsContainer_0.MoveElementToGroup(element, group);
         this.igraphicsContainer_0.MoveElementToGroup(element2 as IElement, group);
         this.igraphicsContainer_0.AddElement(group as IElement, 0);
     }
     if (this.mapGridBorderPropertyPage_0.IsGenerateGraphics)
     {
         this.m_pMapGrid.GenerateGraphics(this.imapFrame_0, this.igraphicsContainer_0);
     }
 }
Example #2
0
        private IElement method_8(IPoint ipoint_0, ILineSymbol ilineSymbol_0, string string_1)
        {
            IGroupElement element  = new GroupElementClass();
            IPolyline     polyline = new PolylineClass();
            object        missing  = Type.Missing;
            IPoint        inPoint  = new PointClass();

            inPoint.PutCoords(ipoint_0.X + (this.double_2 / 10.0), ipoint_0.Y - (this.double_3 / 2.0));
            (polyline as IPointCollection).AddPoint(inPoint, ref missing, ref missing);
            inPoint = new PointClass();
            inPoint.PutCoords(ipoint_0.X + (this.double_2 * 0.9), ipoint_0.Y - (this.double_3 / 2.0));
            (polyline as IPointCollection).AddPoint(inPoint, ref missing, ref missing);
            IElement element2 = new LineElementClass
            {
                Geometry = polyline
            };

            (element2 as ILineElement).Symbol = ilineSymbol_0;
            element.AddElement(element2);
            if (this.bool_1)
            {
                element.AddElement(this.method_9(ipoint_0));
            }
            if (string_1.Length > 0)
            {
                element.AddElement(this.method_12(ipoint_0, string_1, 10));
            }
            return(element as IElement);
        }
Example #3
0
        private void method_4(IGraphicsContainer igraphicsContainer_0, IEnvelope ienvelope_0)
        {
            IGroupElement2           element          = null;
            IGraphicsContainerSelect select           = igraphicsContainer_0 as IGraphicsContainerSelect;
            IEnumElement             selectedElements = select.SelectedElements;

            selectedElements.Reset();
            IElement element3 = selectedElements.Next();

            element = new GroupElementClass();
            (element as IElement).Geometry = ienvelope_0;
            while (element3 != null)
            {
                element.AddElement(element3);
                element.Refresh();
                element3 = selectedElements.Next();
            }
            igraphicsContainer_0.AddElement(element as IElement, -1);
            (element as IElement).QueryBounds((igraphicsContainer_0 as IActiveView).ScreenDisplay, ienvelope_0);
            selectedElements.Reset();
            for (element3 = selectedElements.Next(); element3 != null; element3 = selectedElements.Next())
            {
                igraphicsContainer_0.DeleteElement(element3);
            }
            select.SelectElement(element as IElement);
        }
        private int AddCepGraphic(IPoint point, IList <double> circleRadii)
        {
            //Create a new center point graphic
            IMarkerSymbol symbol = new SimpleMarkerSymbolClass();

            symbol.Color = EsriColor(Defaults.CepCenterPointColor);
            symbol.Size  = Defaults.CepCenterPointSize;
            IElement centerPoint = new MarkerElementClass();

            ((IMarkerElement)centerPoint).Symbol = symbol;
            centerPoint.Geometry = point;

            //Create a graphic group and add the center point graphic
            IGroupElement group = new GroupElementClass();

            group.AddElement(centerPoint);

            //Add the circles to the group
            for (int i = 0; i < circleRadii.Count; i++)
            {
                IConstructCircularArc arc = new CircularArcClass();
                arc.ConstructCircle(point, circleRadii[i], false);
                IGeometry polygon = new PolygonClass();
                ((ISegmentCollection)polygon).AddSegment((ISegment)arc);
                IElement circle = new CircleElementClass();
                circle.Geometry = polygon;
                Color circleColor = Defaults.CepCircleOutlineColors.Length > i
                                  ? Defaults.CepCircleOutlineColors[i]
                                  : Defaults.CepCircleOutlineColors[Defaults.CepCircleOutlineColors.Length - 1];
                double circleWidth = Defaults.CepCircleOutlineWidths.Length > i
                                   ? Defaults.CepCircleOutlineWidths[i]
                                   : Defaults.CepCircleOutlineWidths[Defaults.CepCircleOutlineWidths.Length - 1];
                ((IFillShapeElement)circle).Symbol = GetCircleSymbol(circleColor, circleWidth);
                group.AddElement(circle);
            }

            //Give it the group an id number and add it to the graphics layer
            _elementId++;
            ((IElementProperties)group).CustomProperty = _elementId;
            ((IGraphicsContainer)GraphicsLayer).AddElement((IElement)group, 0);
            return(_elementId);
        }
Example #5
0
        private IElement method_11(IPoint ipoint_0, IFillSymbol ifillSymbol_0, string string_1)
        {
            IGroupElement element = new GroupElementClass();
            IPolygon      polygon = new PolygonClass();
            object        missing = Type.Missing;
            IPoint        inPoint = new PointClass();

            inPoint.PutCoords(ipoint_0.X, ipoint_0.Y);
            (polygon as IPointCollection).AddPoint(inPoint, ref missing, ref missing);
            inPoint = new PointClass();
            inPoint.PutCoords(ipoint_0.X, ipoint_0.Y - this.double_3);
            (polygon as IPointCollection).AddPoint(inPoint, ref missing, ref missing);
            inPoint = new PointClass();
            inPoint.PutCoords(ipoint_0.X + this.double_2, ipoint_0.Y - this.double_3);
            (polygon as IPointCollection).AddPoint(inPoint, ref missing, ref missing);
            inPoint = new PointClass();
            inPoint.PutCoords(ipoint_0.X + this.double_2, ipoint_0.Y);
            (polygon as IPointCollection).AddPoint(inPoint, ref missing, ref missing);
            inPoint = new PointClass();
            inPoint.PutCoords(ipoint_0.X, ipoint_0.Y);
            (polygon as IPointCollection).AddPoint(inPoint, ref missing, ref missing);
            IElement element2 = new PolygonElementClass
            {
                Geometry = polygon
            };

            (element2 as IFillShapeElement).Symbol = ifillSymbol_0;
            element.AddElement(element2);
            if (this.bool_1)
            {
                element.AddElement(this.method_9(ipoint_0));
            }
            if (string_1.Length > 0)
            {
                element.AddElement(this.method_12(ipoint_0, string_1, 10));
            }
            return(element as IElement);
        }
Example #6
0
        private IElement method_7(IPoint ipoint_0, IMarkerSymbol imarkerSymbol_0, string string_1)
        {
            IGroupElement element = new GroupElementClass();
            IPoint        point   = new PointClass();

            point.PutCoords(ipoint_0.X + (this.double_2 / 2.0), ipoint_0.Y - (this.double_3 / 2.0));
            IElement element2 = new MarkerElementClass
            {
                Geometry = point
            };

            (element2 as IMarkerElement).Symbol = imarkerSymbol_0;
            element.AddElement(element2);
            if (this.bool_1)
            {
                element.AddElement(this.method_9(ipoint_0));
            }
            if (string_1.Length > 0)
            {
                element.AddElement(this.method_12(ipoint_0, string_1, 10));
            }
            return(element as IElement);
        }
Example #7
0
        public void Create(IActiveView iactiveView_0, IPoint ipoint_0)
        {
            int num = this.lstSymbol.Count / this.int_0;

            if ((num * this.double_0) < this.lstSymbol.Count)
            {
                num++;
            }
            int           num2   = 0;
            double        num3   = 0.0;
            double        height = 0.0;
            IGroupElement data   = new GroupElementClass();

            ipoint_0.X += 0.1;
            ipoint_0.Y += 0.1;
            if (this.string_0.Length > 0)
            {
                IElement  element  = this.method_5(ipoint_0);
                IEnvelope envelope = new EnvelopeClass();
                element.QueryBounds(iactiveView_0.ScreenDisplay, envelope);
                height = envelope.Height;
                data.AddElement(element);
            }
            double    x      = ipoint_0.X;
            double    y      = ipoint_0.Y - height;
            IPoint    point  = new PointClass();
            IEnvelope bounds = new EnvelopeClass();

            for (int i = 0; i < this.lstSymbol.Count; i++)
            {
                ISymbol local1 = this.lstSymbol[i];
                point.PutCoords(x, y);
                IElement element3 = this.method_6(point, this.lstSymbol[i], this.lstSymHeader[i]);
                element3.QueryBounds(iactiveView_0.ScreenDisplay, bounds);
                if (element3 is IGroupElement)
                {
                    for (int j = 0; j < (element3 as IGroupElement).ElementCount; j++)
                    {
                        data.AddElement((element3 as IGroupElement).get_Element(j));
                    }
                }
                else
                {
                    data.AddElement(element3);
                }
                (data as IGroupElement2).Refresh();
                num3 = (num3 > bounds.Width) ? num3 : bounds.Width;
                y    = (y - this.double_3) - this.double_1;
                num2++;
                if (num2 == num)
                {
                    y    = ipoint_0.Y - height;
                    x   += num3 + this.double_0;
                    num2 = 0;
                    num3 = 0.0;
                }
            }
            IEnvelope envelope3 = new EnvelopeClass();

            (data as IElement).QueryBounds(iactiveView_0.ScreenDisplay, envelope3);
            envelope3.Expand(0.05, 0.05, false);
            try
            {
                if (this.bool_0)
                {
                    data.AddElement(this.method_10(envelope3));
                }
                (data as IElement).QueryBounds(iactiveView_0.ScreenDisplay, envelope3);
                (data as ITransform2D).Scale(envelope3.UpperLeft, 1.0, 1.0);
                (iactiveView_0 as IGraphicsContainer).AddElement(data as IElement, -1);
            }
            catch (Exception)
            {
            }
            iactiveView_0.PartialRefresh(esriViewDrawPhase.esriViewGraphics, data, null);
        }
Example #8
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     try
     {
         bool flag = false;
         if (this.chkNewFrameElement.Checked)
         {
             IGraphicsContainerSelect select;
             IEnumElement             selectedElements;
             IGraphicsContainer       container;
             flag = true;
             IFrameElement element         = new FrameElementClass();
             IEnvelope     printableBounds = null;
             IElement      element2        = null;
             if (this.rdoPlaceSelectElement.Checked)
             {
                 select           = this.ipageLayout_0 as IGraphicsContainerSelect;
                 selectedElements = select.SelectedElements;
                 selectedElements.Reset();
                 element2 = selectedElements.Next();
                 if (element2 == null)
                 {
                     return;
                 }
                 printableBounds = element2.Geometry.Envelope;
                 for (element2 = selectedElements.Next(); element2 != null; element2 = selectedElements.Next())
                 {
                     printableBounds.Union(element2.Geometry.Envelope);
                 }
             }
             else if (this.rdoPlaceAllElement.Checked)
             {
                 container = this.ipageLayout_0 as IGraphicsContainer;
                 container.Reset();
                 element2 = container.Next();
                 if (element2 == null)
                 {
                     return;
                 }
                 printableBounds = element2.Geometry.Envelope;
                 for (element2 = container.Next(); element2 != null; element2 = container.Next())
                 {
                     printableBounds.Union(element2.Geometry.Envelope);
                 }
             }
             else
             {
                 printableBounds = this.ipageLayout_0.Page.PrintableBounds;
             }
             printableBounds.Expand(0.5, 0.5, false);
             (element as IElement).Geometry = printableBounds;
             if (this.chkGroup.Checked)
             {
                 IGroupElement group = new GroupElementClass();
                 container = this.ipageLayout_0 as IGraphicsContainer;
                 container.MoveElementToGroup(element as IElement, group);
                 select           = this.ipageLayout_0 as IGraphicsContainerSelect;
                 selectedElements = null;
                 if (this.rdoPlaceAllElement.Checked)
                 {
                     select.SelectAllElements();
                 }
                 selectedElements = select.SelectedElements;
                 selectedElements.Reset();
                 for (element2 = selectedElements.Next(); element2 != null; element2 = selectedElements.Next())
                 {
                     container.MoveElementToGroup(element2, group);
                 }
                 this.iframeElement_0 = group as IFrameElement;
             }
             else
             {
                 this.iframeElement_0 = element;
             }
         }
         IStyleGalleryItem selectStyleGalleryItem = null;
         selectStyleGalleryItem = this.cboBorder.GetSelectStyleGalleryItem();
         IBorder item = null;
         if (selectStyleGalleryItem != null)
         {
             item = selectStyleGalleryItem.Item as IBorder;
             (item as IFrameDecoration).HorizontalSpacing = (double)this.txtGap.Value;
             (item as IFrameDecoration).VerticalSpacing   = (double)this.txtGap.Value;
             (item as IFrameDecoration).CornerRounding    = (short)this.txtRound.Value;
         }
         IBackground background = null;
         selectStyleGalleryItem = this.cboBackground.GetSelectStyleGalleryItem();
         if (selectStyleGalleryItem != null)
         {
             background = selectStyleGalleryItem.Item as IBackground;
             (background as IFrameDecoration).HorizontalSpacing = (double)this.txtGap.Value;
             (background as IFrameDecoration).VerticalSpacing   = (double)this.txtGap.Value;
             (background as IFrameDecoration).CornerRounding    = (short)this.txtRound.Value;
         }
         IShadow shadow = null;
         selectStyleGalleryItem = this.cboShadow.GetSelectStyleGalleryItem();
         if (selectStyleGalleryItem != null)
         {
             shadow = selectStyleGalleryItem.Item as IShadow;
             (shadow as IFrameDecoration).HorizontalSpacing = (double)this.txtGap.Value;
             (shadow as IFrameDecoration).VerticalSpacing   = (double)this.txtGap.Value;
             (shadow as IFrameDecoration).CornerRounding    = (short)this.txtRound.Value;
         }
         this.iframeElement_0.Border     = item;
         this.iframeElement_0.Background = background;
         (this.iframeElement_0 as IFrameProperties).Shadow = shadow;
         if (flag)
         {
             (this.ipageLayout_0 as IGraphicsContainer).AddElement(this.iframeElement_0 as IElement, 0);
             ElementOperator.FocusOneElement(this.ipageLayout_0 as IActiveView, this.iframeElement_0 as IElement);
         }
     }
     catch (Exception exception)
     {
         Logger.Current.Error("", exception, "");
     }
 }
        private static void DrawMapUnits(IEnvelope Envelope, bool showText, double ColumnX)
        {
            // BOX DIMENSIONS AND UNIFORM SYMBOL ITEMS
            double Text2BoxY = 0.2; //Y distance between the bottom of text and the next box
            double Text2BoxX = 0.1; //X distance between a box and the text that describes it
            double BoxX      = 0.4; //Width
            double BoxY      = 0.3; //Height

            // Setup a black color object, black outline
            IRgbColor BlackInsides = new ESRI.ArcGIS.Display.RgbColorClass();

            BlackInsides.Blue  = 0;
            BlackInsides.Red   = 0;
            BlackInsides.Green = 0;

            ILineSymbol BlackOutsides = new SimpleLineSymbolClass();

            BlackOutsides.Width = 1;
            BlackOutsides.Color = BlackInsides;

            // Whole bunch of variables to use while going through the loop below...
            #region Variables Galore!!!
            IMxDocument        Doc = ArcMap.Document;
            IPageLayout        pageLayout = Doc.ActiveView as IPageLayout;
            IGraphicsContainer GraphicsContainer = pageLayout as IGraphicsContainer;
            double             Xcoord, Ycoord;
            Xcoord = Envelope.XMin;
            Ycoord = Envelope.YMax;
            double                      IndentTerm   = 0;
            IPoint                      Point        = null;
            double                      StringLength = 0;
            string                      LegendText   = "";
            string                      ItemName     = "";
            string                      ItemDesc     = "";
            IElement                    Ele          = null;
            IEnvelope                   TempEnv      = null;
            IRgbColor                   BoxColr      = null;
            ISimpleFillSymbol           FillSym      = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
            IFillShapeElement           FillEle      = null;
            IEnvelope                   FillEnv      = new EnvelopeClass();
            WKSEnvelope                 Patch        = new WKSEnvelope();
            IGeometry                   Geo          = null;
            string                      LabelText    = "";
            ESRI.ArcGIS.Geometry.IPoint LabelPoint   = new ESRI.ArcGIS.Geometry.PointClass();

            // Get the transparency of the MapUnitPolys Layer
            double transparency = 100;
            try
            {
                IFeatureLayer polyLayer    = commonFunctions.FindFeatureLayer(ArcMap.Editor.EditWorkspace, "MapUnitPolys");
                ILayerEffects layerEffects = polyLayer as ILayerEffects;
                transparency = layerEffects.Transparency;
            }
            catch { }

            #endregion

            // Get a reference to the DescriptionOfMapUnits entries
            var sortedDmuEntries = GetDmuSortedByHierarchy();

            // Loop through legend records
            foreach (KeyValuePair <string, DescriptionOfMapUnitsAccess.DescriptionOfMapUnit> aDictionaryEntry in sortedDmuEntries)
            {
                // Grab the DMU entry itself
                DescriptionOfMapUnitsAccess.DescriptionOfMapUnit aDescription = aDictionaryEntry.Value;
                bool isHeading = (aDescription.ParagraphStyle.Contains("Heading"));


                // Find out how far to indent the legend item
                // Strip periods from the HierarchyKey, divide by 4, which is the length of a segment of the key
                IndentTerm = aDescription.HierarchyKey.Replace(".", "").Length / 4;

                // Get the coordinates of the text for the legend entry - upper left corner
                // Xcoord starts at Envelope.XMin, Ycoord is Envelope.YMax: Upper left corner
                Point = new PointClass();
                double xAdditions = 0;
                if (isHeading)
                {
                    // Xcoord plus (indentation), Ycoord
                    xAdditions = 0.2 * (IndentTerm - 1);
                }
                else
                {
                    //Xcoord plus (indentation) + (Box width and margin), Ycoord
                    xAdditions = 0.2 * (IndentTerm - 1) + BoxX + Text2BoxX;
                }
                Point.PutCoords(Xcoord + xAdditions, Ycoord);

                // StringLength is the width remaining in the envelope in which the text has to fit IN PIXELS.
                StringLength = 72 * (Envelope.Width - xAdditions);

                // Fix a couple of special characters in the legend string.
                // Then amalgamate item name and description
                ItemName = FixLegendTextCharacters(aDescription.Name);
                if (!isHeading)
                {
                    LegendText = ItemName + " - " + FixLegendTextCharacters(aDescription.Description);
                }
                else
                {
                    LegendText = ItemName;
                }



                // Format the legend text if it is not a heading. If it is, we're fine.
                if (!isHeading)
                {
                    LegendText = GetFormattedString(LegendText, "Arial", 8, StringLength, 8);
                }

                // Boldify the ItemName
                LegendText = LegendText.Replace(ItemName, "<bol>" + ItemName + "</bol>");

                // If the StratCorDiagram is being drawn
                if (showText == false)
                {
                    LegendText   = ".";     // placeholder
                    StringLength = 1;
                }

                // See if this legend item should be placed on a new column
                Ele = MakeTextElement(Point, LegendText, "Arial") as IElement;

                TempEnv = new EnvelopeClass();
                Ele.QueryBounds(Doc.ActiveView.ScreenDisplay, TempEnv);

                // If the height of the formatted text is larger than the box + space specified
                if (TempEnv.Height > BoxY + Text2BoxY)
                {
                    // If the text will spill out below the envelope drawn by the user
                    if (Ycoord - TempEnv.Height < Envelope.YMin)
                    {
                        // Move to a new column - the last number is a fudge factor, looks like it is in inches
                        Xcoord = Xcoord + BoxX + Text2BoxX + StringLength / 72 + ColumnX;
                        // Move to the top
                        Ycoord = Envelope.YMax;
                        // Recreate the text element
                        Point.PutCoords(Xcoord + 0.2 * (IndentTerm - 1) + BoxX + Text2BoxX, Ycoord);
                        Ele = MakeTextElement(Point, LegendText, "Arial") as IElement;
                    }
                }
                else     // The height of the formatted text is not larger than the box + space defined
                {
                    // If the box itself will spill out below the envelope drawn by the user
                    if (Ycoord - (BoxY + Text2BoxY) < Envelope.YMin)
                    {
                        // Move to a new column
                        Xcoord = Xcoord + BoxX + Text2BoxX + StringLength / 72 + ColumnX;
                        // Move to the top
                        Ycoord = Envelope.YMax;
                        // Recreate the text element
                        Point.PutCoords(Xcoord + 0.2 * (IndentTerm - 1) + BoxX + Text2BoxX, Ycoord);
                        Ele = MakeTextElement(Point, LegendText, "Arial") as IElement;
                    }
                }

                // Only write the legend text if the legend is being drawn (not the StratCorDiagram)
                if (showText == true)
                {
                    GraphicsContainer.AddElement(Ele, 0);
                }

                if (!isHeading)
                {
                    FillEnv = new EnvelopeClass();

                    Patch.XMin = Point.X - BoxX - Text2BoxX;
                    Patch.YMax = Point.Y;
                    Patch.XMax = Point.X - Text2BoxX;
                    Patch.YMin = Point.Y - BoxY;
                    FillEnv.PutCoords(Patch.XMin, Patch.YMin, Patch.XMax, Patch.YMax);
                    Geo = FillEnv as IGeometry;

                    // Get the color of the box
                    BoxColr = new RgbColorClass();
                    if (aDescription.AreaFillRGB == null)
                    {
                        BoxColr.Red   = 255;
                        BoxColr.Green = 0;
                        BoxColr.Blue  = 0;
                    }
                    else
                    {
                        BoxColr.Red   = int.Parse(aDescription.AreaFillRGB.Split(';')[0]);
                        BoxColr.Green = int.Parse(aDescription.AreaFillRGB.Split(';')[1]);
                        BoxColr.Blue  = int.Parse(aDescription.AreaFillRGB.Split(';')[2]);
                    }

                    // Set the transparency for the legend color boxes
                    BoxColr.Red   = (int)((255 - BoxColr.Red) * transparency / 100 + BoxColr.Red);
                    BoxColr.Green = (int)((255 - BoxColr.Green) * transparency / 100 + BoxColr.Green);
                    BoxColr.Blue  = (int)((255 - BoxColr.Blue) * transparency / 100 + BoxColr.Blue);

                    // Draw the fill
                    FillSym         = new SimpleFillSymbolClass();
                    FillSym.Color   = BoxColr;
                    FillSym.Style   = esriSimpleFillStyle.esriSFSSolid;
                    FillSym.Outline = BlackOutsides;

                    FillEle = CreateFillElement(Geo, FillSym) as IFillShapeElement;

                    // Label the box
                    LabelText = aDescription.Label;

                    // Subscripting!!

                    for (int i = 0; i < LabelText.Length; i++)
                    {
                        string thisBit = LabelText.Substring(i, 1);
                        int    num;
                        if (int.TryParse(thisBit, out num)) // Checks if the character is numeric
                        {
                            LabelText = LabelText.Replace(thisBit, "<sub>" + thisBit + "</sub>");
                            i         = i + 5;
                        }
                    }
                    LabelText = LabelText.Replace("ir", "i<sub>r</sub>");
                    LabelText = LabelText.Replace("yc", "y<sub>c</sub>");

                    // Center the label
                    LabelPoint   = new PointClass();
                    LabelPoint.X = Point.X - BoxX / 2 - Text2BoxX;
                    LabelPoint.Y = Point.Y - BoxY / 2;

                    //LabelText = GetFormattedString(LabelText, "FGDCGeoAge", 8, StringLength, 0);
                    Ele = MakeTextElement(LabelPoint, LabelText, "FGDCGeoAge", true) as IElement;

                    // Add the box and label
                    IGroupElement3 group = new GroupElementClass();
                    group.AddElement(FillEle as IElement);
                    group.AddElement(Ele);
                    GraphicsContainer.AddElement(group as IElement, 0);
                }

                // Do a partial refresh
                //Doc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

                // Setup the Y coordinates for the next entry
                // if the height of this item's text is bigger than the minimum distance between text and box
                if (TempEnv.Height > Text2BoxY)
                {
                    // Subtract the box height and the text height to get the new ycoord
                    Ycoord = Ycoord - (TempEnv.Height + Text2BoxY);
                }
                else
                {
                    if (isHeading)
                    {
                        Ycoord = Ycoord - (TempEnv.Height + Text2BoxY);
                    }
                    else
                    {
                        Ycoord = Ycoord - (BoxY + Text2BoxY);
                    }
                }
            }

            // Done, refresh, turn off the tool
            Doc.ActiveView.Refresh();
            ArcMap.Application.CurrentTool = null;
        }
Example #10
0
        public void Create(IActiveView iactiveView_0, IEnvelope ienvelope_0)
        {
            IPoint upperLeft = ienvelope_0.UpperLeft;
            int    num       = this.ilist_0.Count / this.int_0;

            if ((num * this.double_0) < this.ilist_0.Count)
            {
                num++;
            }
            int    num2   = 0;
            double num3   = 0.0;
            double height = 0.0;

            upperLeft.X += 0.1;
            upperLeft.Y += 0.1;
            IGroupElement data = new GroupElementClass();

            if (this.string_0.Length > 0)
            {
                IElement  element  = this.method_5(upperLeft);
                IEnvelope envelope = new EnvelopeClass();
                element.QueryBounds(iactiveView_0.ScreenDisplay, envelope);
                height = envelope.Height;
                data.AddElement(element);
            }
            double    x      = upperLeft.X;
            double    y      = upperLeft.Y - height;
            IPoint    point2 = new PointClass();
            IEnvelope bounds = new EnvelopeClass();

            for (int i = 0; i < this.ilist_0.Count; i++)
            {
                ISymbol local1 = this.ilist_0[i];
                point2.PutCoords(x, y);
                IElement element3 = this.method_6(point2, this.ilist_0[i], this.ilist_1[i]);
                element3.QueryBounds(iactiveView_0.ScreenDisplay, bounds);
                if (element3 is IGroupElement)
                {
                    for (int j = 0; j < (element3 as IGroupElement).ElementCount; j++)
                    {
                        data.AddElement((element3 as IGroupElement).get_Element(j));
                    }
                }
                else
                {
                    data.AddElement(element3);
                }
                num3 = (num3 > bounds.Width) ? num3 : bounds.Width;
                y    = (y - this.double_3) - this.double_1;
                num2++;
                if (num2 == num)
                {
                    y    = upperLeft.Y - height;
                    x   += num3 + this.double_0;
                    num2 = 0;
                }
            }
            (data as IElement).QueryBounds(iactiveView_0.ScreenDisplay, bounds);
            double sx = ienvelope_0.Width / bounds.Width;
            double sy = ienvelope_0.Height / bounds.Height;

            ienvelope_0.Expand(-0.05, -0.05, false);
            (data as ITransform2D).Scale(ienvelope_0.UpperLeft, sx, sy);
            ienvelope_0.Expand(0.05, 0.05, false);
            if (this.bool_0)
            {
                data.AddElement(this.method_10(ienvelope_0));
            }
            (iactiveView_0 as IGraphicsContainer).AddElement(data as IElement, -1);
            iactiveView_0.PartialRefresh(esriViewDrawPhase.esriViewGraphics, data, null);
        }
Example #11
0
        public IElement CreateElement(IActiveView iactiveView_0, IPoint ipoint_0)
        {
            int num = this.ilist_0.Count / this.int_0;

            if ((num * this.double_0) < this.ilist_0.Count)
            {
                num++;
            }
            int           num2    = 0;
            double        num3    = 0.0;
            double        height  = 0.0;
            IGroupElement element = new GroupElementClass();

            ipoint_0.X += 0.1;
            ipoint_0.Y += 0.1;
            if (this.string_0.Length > 0)
            {
                IElement  element2 = this.method_5(ipoint_0);
                IEnvelope envelope = new EnvelopeClass();
                element2.QueryBounds(iactiveView_0.ScreenDisplay, envelope);
                height = envelope.Height;
                element.AddElement(element2);
            }
            double    x      = ipoint_0.X;
            double    y      = ipoint_0.Y - height;
            IPoint    point  = new PointClass();
            IEnvelope bounds = new EnvelopeClass();

            for (int i = 0; i < this.ilist_0.Count; i++)
            {
                ISymbol local1 = this.ilist_0[i];
                point.PutCoords(x, y);
                IElement element3 = this.method_6(point, this.ilist_0[i], this.ilist_1[i]);
                element3.QueryBounds(iactiveView_0.ScreenDisplay, bounds);
                if (element3 is IGroupElement)
                {
                    for (int j = 0; j < (element3 as IGroupElement).ElementCount; j++)
                    {
                        element.AddElement((element3 as IGroupElement).get_Element(j));
                    }
                }
                else
                {
                    element.AddElement(element3);
                }
                (element as IGroupElement2).Refresh();
                num3 = (num3 > bounds.Width) ? num3 : bounds.Width;
                y    = (y - this.double_3) - this.double_1;
                num2++;
                if (num2 == num)
                {
                    y    = ipoint_0.Y - height;
                    x   += num3 + this.double_0;
                    num2 = 0;
                    num3 = 0.0;
                }
            }
            IEnvelope envelope3 = new EnvelopeClass();

            (element as IElement).QueryBounds(iactiveView_0.ScreenDisplay, envelope3);
            envelope3.Expand(0.05, 0.05, false);
            try
            {
                if (this.bool_0)
                {
                    element.AddElement(this.method_10(envelope3));
                }
                (element as IElement).QueryBounds(iactiveView_0.ScreenDisplay, envelope3);
                (element as ITransform2D).Scale(envelope3.UpperLeft, 1.0, 1.0);
            }
            catch (Exception)
            {
            }
            (element as IElementProperties).Name = "图例";
            return(element as IElement);
        }
Example #12
0
        private void theForm_BoxChange(object sender, EventArgs e)
        {
            bool bNeedRefresh = false;

            ISDUTExtension theExt = this.Extension;
            IGraphicsContainer theGCont = util.GraphicsHelper.get_GraphicsContainer(theExt.FocusMap);
            ui.CreateWellsiteBoxForm theForm = (ui.CreateWellsiteBoxForm)sender;

            IPolygon theBox = null;
            if (double.IsNaN(theForm.Orientation) == false && double.IsNaN(theForm.BoxSize) == false)
            {
                theBox = this.CreateBox(this._Wellsite, theForm.Orientation, theForm.BoxSize, theForm.SizeUnits);
                theBox.Project(theExt.FocusMap.SpatialReference);
            }

            // Clear existing feedback
            if (this._Feedback != null)
            {
                theGCont.DeleteElement(this._Feedback);
                this._Feedback = null;
                bNeedRefresh = true;
            }

            // Create new graphic
            if (theBox != null)
            {
                object theMissing = Type.Missing;

                IElement theBoxE = new PolygonElementClass();
                theBoxE.Geometry = theBox;
                ((IFillShapeElement)theBoxE).Symbol = util.GraphicsHelper.get_SimplePolygonSymbol(
                    util.GraphicsHelper.get_RgbColor(0, 0, 0), esriSimpleFillStyle.esriSFSHollow,
                    util.GraphicsHelper.get_SimpleLineSymbol(
                    util.GraphicsHelper.get_RgbColor(0, 0, 0), 2.0, esriSimpleLineStyle.esriSLSSolid));

                ILine theLine = new LineClass();
                theLine.PutCoords(this._Wellsite, theBox.FromPoint);
                ISegmentCollection theSegColl = new PolylineClass();
                theSegColl.AddSegment((ISegment)theLine, ref theMissing, ref theMissing);
                IElement theLineE = new LineElementClass();
                theLineE.Geometry = (IGeometry)theSegColl;

                IGroupElement theGroupE = new GroupElementClass();
                theGroupE.AddElement(theBoxE);
                theGroupE.AddElement(theLineE);

                this._Feedback = (IElement)theGroupE;
                theGCont.AddElement(this._Feedback, 0);

                bNeedRefresh = true;
            }

            // Refresh the graphics in the map
            if (bNeedRefresh)
            {
                IActiveView theAV = (IActiveView)theExt.FocusMap;
                theAV.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, theAV.Extent);
            }
        }
Example #13
0
        public IElement CreateJionTab(IActiveView iactiveView_0, IPoint ipoint_0)
        {
            IGroupElement element = new GroupElementClass();

            (element as IElementProperties).Name = "接图表";
            (element as IElementProperties).Type = "接图表";
            new PointClass();
            new TextElementClass();
            new TextElementClass();
            new TextElementClass();
            new TextElementClass();
            new TextElementClass();
            new TextElementClass();
            new TextElementClass();
            new TextElementClass();
            ILineElement     element2  = null;
            ILineSymbol      symbol    = null;
            double           num       = this.double_1 / 3.0;
            double           num2      = this.double_0 / 3.0;
            double           num3      = 0.3;
            object           missing   = Type.Missing;
            IElement         element3  = new LineElementClass();
            IElement         element4  = new LineElementClass();
            IElement         element5  = new LineElementClass();
            IElement         element6  = new LineElementClass();
            IElement         element7  = new LineElementClass();
            IPolyline        polyline  = new PolylineClass();
            IPolyline        polyline2 = new PolylineClass();
            IPolyline        polyline3 = new PolylineClass();
            IPolyline        polyline4 = new PolylineClass();
            IPolyline        polyline5 = new PolylineClass();
            IPointCollection points    = polyline as IPointCollection;
            IPoint           inPoint   = new PointClass();
            IPoint           point2    = new PointClass();
            IPoint           point3    = new PointClass();
            IPoint           point4    = new PointClass();

            try
            {
                symbol          = this.ilineSymbol_0;
                element2        = element3 as ILineElement;
                element2.Symbol = symbol;
                element2        = element4 as ILineElement;
                element2.Symbol = symbol;
                element2        = element5 as ILineElement;
                element2.Symbol = symbol;
                element2        = element6 as ILineElement;
                element2.Symbol = symbol;
                element2        = element7 as ILineElement;
                element2.Symbol = symbol;
                point2.PutCoords(ipoint_0.X, ipoint_0.Y + num3);
                inPoint.PutCoords(ipoint_0.X, (ipoint_0.Y + num3) + this.double_1);
                point3.PutCoords(ipoint_0.X + this.double_0, ipoint_0.Y + num3);
                point4.PutCoords(ipoint_0.X + this.double_0, (ipoint_0.Y + num3) + this.double_1);
                points.AddPoint(inPoint, ref missing, ref missing);
                points.AddPoint(point2, ref missing, ref missing);
                points.AddPoint(point3, ref missing, ref missing);
                points.AddPoint(point4, ref missing, ref missing);
                points.AddPoint(inPoint, ref missing, ref missing);
                element3.Geometry = polyline;
                element.AddElement(element3);
                IPoint point5 = new PointClass();
                IPoint point6 = new PointClass();
                point5.PutCoords(inPoint.X, inPoint.Y - num);
                point6.PutCoords(point4.X, point4.Y - num);
                points = polyline2 as IPointCollection;
                points.AddPoint(point5, ref missing, ref missing);
                points.AddPoint(point6, ref missing, ref missing);
                element4.Geometry = polyline2;
                element.AddElement(element4);
                point5.PutCoords(inPoint.X, inPoint.Y - (num * 2.0));
                point6.PutCoords(point4.X, point4.Y - (num * 2.0));
                points = polyline3 as IPointCollection;
                points.AddPoint(point5, ref missing, ref missing);
                points.AddPoint(point6, ref missing, ref missing);
                element5.Geometry = polyline3;
                element.AddElement(element5);
                point5.PutCoords(inPoint.X + num2, inPoint.Y);
                point6.PutCoords(inPoint.X + num2, point2.Y);
                points = polyline4 as IPointCollection;
                points.AddPoint(point5, ref missing, ref missing);
                points.AddPoint(point6, ref missing, ref missing);
                element6.Geometry = polyline4;
                element.AddElement(element6);
                point5.PutCoords(inPoint.X + (num2 * 2.0), inPoint.Y);
                point6.PutCoords(inPoint.X + (num2 * 2.0), point2.Y);
                points = polyline5 as IPointCollection;
                points.AddPoint(point5, ref missing, ref missing);
                points.AddPoint(point6, ref missing, ref missing);
                element7.Geometry = polyline5;
                element.AddElement(element7);
                IPolygon          polygon   = new PolygonClass();
                IElement          element8  = new PolygonElementClass();
                IPolygonElement   element9  = element8 as IPolygonElement;
                ISimpleFillSymbol symbol2   = new SimpleFillSymbolClass();
                IFillShapeElement element10 = element9 as IFillShapeElement;
                IRgbColor         color     = new RgbColorClass
                {
                    Red   = 0,
                    Green = 0,
                    Blue  = 0
                };
                symbol2.Outline  = this.ilineSymbol_0;
                symbol2.Color    = color;
                symbol2.Style    = esriSimpleFillStyle.esriSFSBackwardDiagonal;
                element10.Symbol = symbol2;
                points           = polygon as IPointCollection;
                point5.PutCoords(inPoint.X + num2, inPoint.Y - num);
                points.AddPoint(point5, ref missing, ref missing);
                point5.PutCoords(inPoint.X + (num2 * 2.0), inPoint.Y - num);
                points.AddPoint(point5, ref missing, ref missing);
                point5.PutCoords(inPoint.X + (num2 * 2.0), inPoint.Y - (num * 2.0));
                points.AddPoint(point5, ref missing, ref missing);
                point5.PutCoords(inPoint.X + num2, inPoint.Y - (num * 2.0));
                points.AddPoint(point5, ref missing, ref missing);
                polygon.Close();
                element8.Geometry = polygon;
                element.AddElement(element8);
                IEnvelope envelope = polygon.Envelope;
                new EnvelopeClass();
                if (this.string_0.Trim().Length > 0)
                {
                    element.AddElement(this.method_0(iactiveView_0, this.string_0, inPoint.X + (num2 / 2.0),
                                                     inPoint.Y - (num / 2.0), envelope));
                }
                if (this.string_1.Trim().Length > 0)
                {
                    element.AddElement(this.method_0(iactiveView_0, this.string_1, inPoint.X + (num2 / 2.0),
                                                     inPoint.Y - (1.5 * num), envelope));
                }
                if (this.string_2.Trim().Length > 0)
                {
                    element.AddElement(this.method_0(iactiveView_0, this.string_2, inPoint.X + (num2 / 2.0),
                                                     inPoint.Y - (2.5 * num), envelope));
                }
                if (this.string_3.Trim().Length > 0)
                {
                    element.AddElement(this.method_0(iactiveView_0, this.string_3, inPoint.X + (1.5 * num2),
                                                     inPoint.Y - (0.5 * num), envelope));
                }
                if (this.string_4.Trim().Length > 0)
                {
                    element.AddElement(this.method_0(iactiveView_0, this.string_4, inPoint.X + (1.5 * num2),
                                                     inPoint.Y - (2.5 * num), envelope));
                }
                if (this.string_5.Trim().Length > 0)
                {
                    element.AddElement(this.method_0(iactiveView_0, this.string_5, inPoint.X + (2.5 * num2),
                                                     inPoint.Y - (0.5 * num), envelope));
                }
                if (this.string_6.Trim().Length > 0)
                {
                    element.AddElement(this.method_0(iactiveView_0, this.string_6, inPoint.X + (2.5 * num2),
                                                     inPoint.Y - (1.5 * num), envelope));
                }
                if (this.string_7.Trim().Length > 0)
                {
                    element.AddElement(this.method_0(iactiveView_0, this.string_7, inPoint.X + (2.5 * num2),
                                                     inPoint.Y - (2.5 * num), envelope));
                }
            }
            catch (Exception)
            {
            }
            return(element as IElement);
        }
Example #14
0
        private static void DrawMapUnits(IEnvelope Envelope, bool showText, double ColumnX)
        {
            // BOX DIMENSIONS AND UNIFORM SYMBOL ITEMS
            double Text2BoxY = 0.2; //Y distance between the bottom of text and the next box
            double Text2BoxX = 0.1; //X distance between a box and the text that describes it
            double BoxX = 0.4; //Width
            double BoxY = 0.3; //Height

            // Setup a black color object, black outline
            IRgbColor BlackInsides = new ESRI.ArcGIS.Display.RgbColorClass();
            BlackInsides.Blue = 0;
            BlackInsides.Red = 0;
            BlackInsides.Green = 0;

            ILineSymbol BlackOutsides = new SimpleLineSymbolClass();
            BlackOutsides.Width = 1;
            BlackOutsides.Color = BlackInsides;

            // Whole bunch of variables to use while going through the loop below...
            #region Variables Galore!!!
            IMxDocument Doc = ArcMap.Document;
            IPageLayout pageLayout = Doc.ActiveView as IPageLayout;
            IGraphicsContainer GraphicsContainer = pageLayout as IGraphicsContainer;
            double Xcoord, Ycoord;
            Xcoord = Envelope.XMin;
            Ycoord = Envelope.YMax;
            double IndentTerm = 0;
            IPoint Point = null;
            double StringLength = 0;
            string LegendText = "";
            string ItemName = "";
            string ItemDesc = "";
            IElement Ele = null;
            IEnvelope TempEnv = null;
            IRgbColor BoxColr = null;
            ISimpleFillSymbol FillSym = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
            IFillShapeElement FillEle = null;
            IEnvelope FillEnv = new EnvelopeClass();
            WKSEnvelope Patch = new WKSEnvelope();
            IGeometry Geo = null;
            string LabelText = "";
            ESRI.ArcGIS.Geometry.IPoint LabelPoint = new ESRI.ArcGIS.Geometry.PointClass();

            // Get the transparency of the MapUnitPolys Layer
            double transparency = 100;
            try
            {
                IFeatureLayer polyLayer = commonFunctions.FindFeatureLayer(ArcMap.Editor.EditWorkspace, "MapUnitPolys");
                ILayerEffects layerEffects = polyLayer as ILayerEffects;
                transparency = layerEffects.Transparency;
            }
            catch { }

            #endregion

            // Get a reference to the DescriptionOfMapUnits entries
            var sortedDmuEntries = GetDmuSortedByHierarchy();

            // Loop through legend records
            foreach (KeyValuePair<string, DescriptionOfMapUnitsAccess.DescriptionOfMapUnit> aDictionaryEntry in sortedDmuEntries)
            {

                // Grab the DMU entry itself
                DescriptionOfMapUnitsAccess.DescriptionOfMapUnit aDescription = aDictionaryEntry.Value;
                bool isHeading = (aDescription.ParagraphStyle.Contains("Heading"));

                    // Find out how far to indent the legend item
                    // Strip periods from the HierarchyKey, divide by 4, which is the length of a segment of the key
                    IndentTerm = aDescription.HierarchyKey.Replace(".", "").Length / 4;

                    // Get the coordinates of the text for the legend entry - upper left corner
                    // Xcoord starts at Envelope.XMin, Ycoord is Envelope.YMax: Upper left corner
                    Point = new PointClass();
                    double xAdditions = 0;
                    if (isHeading)
                    {
                        // Xcoord plus (indentation), Ycoord
                        xAdditions = 0.2 * (IndentTerm - 1);
                    }
                    else
                    {
                        //Xcoord plus (indentation) + (Box width and margin), Ycoord
                        xAdditions = 0.2 * (IndentTerm - 1) + BoxX + Text2BoxX;
                    }
                    Point.PutCoords(Xcoord + xAdditions, Ycoord);

                    // StringLength is the width remaining in the envelope in which the text has to fit IN PIXELS.
                    StringLength = 72 * (Envelope.Width - xAdditions);

                    // Fix a couple of special characters in the legend string.
                    // Then amalgamate item name and description
                    ItemName = FixLegendTextCharacters(aDescription.Name);
                    if (!isHeading)
                    {
                        LegendText = ItemName + " - " + FixLegendTextCharacters(aDescription.Description);
                    }
                    else
                    {
                        LegendText = ItemName;
                    }

                    // Format the legend text if it is not a heading. If it is, we're fine.
                    if (!isHeading)
                    {
                        LegendText = GetFormattedString(LegendText, "Arial", 8, StringLength, 8);
                    }

                    // Boldify the ItemName
                    LegendText = LegendText.Replace(ItemName, "<bol>" + ItemName + "</bol>");

                    // If the StratCorDiagram is being drawn
                    if (showText == false)
                    {
                        LegendText = ".";   // placeholder
                        StringLength = 1;
                    }

                    // See if this legend item should be placed on a new column
                    Ele = MakeTextElement(Point, LegendText, "Arial") as IElement;

                    TempEnv = new EnvelopeClass();
                    Ele.QueryBounds(Doc.ActiveView.ScreenDisplay, TempEnv);

                    // If the height of the formatted text is larger than the box + space specified
                    if (TempEnv.Height > BoxY + Text2BoxY)
                    {
                        // If the text will spill out below the envelope drawn by the user
                        if (Ycoord - TempEnv.Height < Envelope.YMin)
                        {
                            // Move to a new column - the last number is a fudge factor, looks like it is in inches
                            Xcoord = Xcoord + BoxX + Text2BoxX + StringLength / 72 + ColumnX;
                            // Move to the top
                            Ycoord = Envelope.YMax;
                            // Recreate the text element
                            Point.PutCoords(Xcoord + 0.2 * (IndentTerm - 1) + BoxX + Text2BoxX, Ycoord);
                            Ele = MakeTextElement(Point, LegendText, "Arial") as IElement;
                        }
                    }
                    else // The height of the formatted text is not larger than the box + space defined
                    {
                        // If the box itself will spill out below the envelope drawn by the user
                        if (Ycoord - (BoxY + Text2BoxY) < Envelope.YMin)
                        {
                            // Move to a new column
                            Xcoord = Xcoord + BoxX + Text2BoxX + StringLength / 72 + ColumnX;
                            // Move to the top
                            Ycoord = Envelope.YMax;
                            // Recreate the text element
                            Point.PutCoords(Xcoord + 0.2 * (IndentTerm - 1) + BoxX + Text2BoxX, Ycoord);
                            Ele = MakeTextElement(Point, LegendText, "Arial") as IElement;
                        }
                    }

                    // Only write the legend text if the legend is being drawn (not the StratCorDiagram)
                    if (showText == true)
                        GraphicsContainer.AddElement(Ele, 0);

                if (!isHeading)
                {
                    FillEnv = new EnvelopeClass();

                    Patch.XMin = Point.X - BoxX - Text2BoxX;
                    Patch.YMax =  Point.Y;
                    Patch.XMax = Point.X - Text2BoxX;
                    Patch.YMin = Point.Y - BoxY;
                    FillEnv.PutCoords(Patch.XMin, Patch.YMin, Patch.XMax, Patch.YMax);
                    Geo = FillEnv as IGeometry;

                    // Get the color of the box
                    BoxColr = new RgbColorClass();
                    if (aDescription.AreaFillRGB == null)
                    {
                        BoxColr.Red = 255;
                        BoxColr.Green = 0;
                        BoxColr.Blue = 0;
                    }
                    else
                    {
                        BoxColr.Red = int.Parse(aDescription.AreaFillRGB.Split(';')[0]);
                        BoxColr.Green = int.Parse(aDescription.AreaFillRGB.Split(';')[1]);
                        BoxColr.Blue = int.Parse(aDescription.AreaFillRGB.Split(';')[2]);
                    }

                    // Set the transparency for the legend color boxes
                    BoxColr.Red = (int)((255 - BoxColr.Red) * transparency/100 + BoxColr.Red);
                    BoxColr.Green = (int)((255 - BoxColr.Green) * transparency / 100 + BoxColr.Green);
                    BoxColr.Blue = (int)((255 - BoxColr.Blue) * transparency / 100 + BoxColr.Blue);

                    // Draw the fill
                    FillSym = new SimpleFillSymbolClass();
                    FillSym.Color = BoxColr;
                    FillSym.Style = esriSimpleFillStyle.esriSFSSolid;
                    FillSym.Outline = BlackOutsides;

                    FillEle = CreateFillElement(Geo, FillSym) as IFillShapeElement;

                    // Label the box
                    LabelText = aDescription.Label;

                    // Subscripting!!

                    for (int i = 0; i < LabelText.Length; i++)
                    {
                        string thisBit = LabelText.Substring(i, 1);
                        int num;
                        if (int.TryParse(thisBit, out num)) // Checks if the character is numeric
                        {
                            LabelText = LabelText.Replace(thisBit, "<sub>" + thisBit + "</sub>");
                            i = i + 5;
                        }
                    }
                    LabelText = LabelText.Replace("ir", "i<sub>r</sub>");
                    LabelText = LabelText.Replace("yc", "y<sub>c</sub>");

                    // Center the label
                    LabelPoint = new PointClass();
                    LabelPoint.X = Point.X - BoxX / 2 - Text2BoxX;
                    LabelPoint.Y = Point.Y - BoxY / 2;

                    //LabelText = GetFormattedString(LabelText, "FGDCGeoAge", 8, StringLength, 0);
                    Ele = MakeTextElement(LabelPoint, LabelText, "FGDCGeoAge", true) as IElement;

                    // Add the box and label
                    IGroupElement3 group = new GroupElementClass();
                    group.AddElement(FillEle as IElement);
                    group.AddElement(Ele);
                    GraphicsContainer.AddElement(group as IElement, 0);
                }

                // Do a partial refresh
                //Doc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

                // Setup the Y coordinates for the next entry
                // if the height of this item's text is bigger than the minimum distance between text and box
                if (TempEnv.Height > Text2BoxY)
                {
                    // Subtract the box height and the text height to get the new ycoord
                    Ycoord = Ycoord - (TempEnv.Height + Text2BoxY);
                }
                else
                {
                    if (isHeading)
                    {
                        Ycoord = Ycoord - (TempEnv.Height + Text2BoxY);
                    }
                    else
                    {
                        Ycoord = Ycoord - (BoxY + Text2BoxY);
                    }
                }
            }

            // Done, refresh, turn off the tool
            Doc.ActiveView.Refresh();
            ArcMap.Application.CurrentTool = null;
        }