Beispiel #1
0
        private void DrawPoint(IPoint pPoint)
        {
            //Draw a red graphic dot on the display at the given point location
            IRgbColor           color      = null;
            ISimpleMarkerSymbol marker     = null;
            IAppDisplay         appDisplay = m_editor.Display as IAppDisplay;

            //Set the symbol (red, size 8)
            color        = new RgbColor();
            color.Red    = 255;
            color.Green  = 0;
            color.Blue   = 0;
            marker       = new SimpleMarkerSymbol();
            marker.Color = color;
            marker.Size  = 8;

            //Draw the point
            appDisplay.StartDrawing(0, (short)esriScreenCache.esriNoScreenCache);
            appDisplay.SetSymbol(marker as ISymbol);
            appDisplay.DrawPoint(pPoint);
            appDisplay.FinishDrawing();
        }
        private static string GetFormattedString(string strTextContent, string strFontName, Single sngFontSizeInPoints, double sngMaxWidthInPoints, long hanging)
        {
            System.Array           varWordArray;
            IMxApplication         pMxApp          = ArcMap.Application as IMxApplication;
            IAppDisplay            pAppDisplay     = pMxApp.Display;
            IDisplayTransformation pTransformation = pAppDisplay.DisplayTransformation;
            IFontDisp   pTextFont   = new stdole.StdFontClass() as IFontDisp;
            ITextSymbol pTextSymbol = new TextSymbolClass();
            double      dblXSize;
            double      dblYSize;
            string      strGoodWidth   = "";
            string      strFinalString = "";
            string      strTestString  = "";
            int         i;

            // Split the string into an array of words
            varWordArray = strTextContent.Split(' ') as System.Array;

            // Set up the Font
            pTextFont.Name = strFontName;
            pTextFont.Size = decimal.Parse(sngFontSizeInPoints.ToString());

            // Setup the Text Symbol
            pTextSymbol.Font = pTextFont;

            // Add each word into the test string and test for width
            pAppDisplay.StartDrawing(pAppDisplay.hDC, 0);
            long linesAdded = 0;

            for (i = 0; i <= (int)varWordArray.GetUpperBound(0); i++)
            {
                if (strGoodWidth != "")
                {
                    strTestString = strGoodWidth + " " + varWordArray.GetValue(i);
                }
                else
                {
                    strTestString = varWordArray.GetValue(i).ToString();
                }

                // Get the TextSize
                pTextSymbol.GetTextSize(pAppDisplay.hDC, pTransformation, strTestString, out dblXSize, out dblYSize);

                // If the word added is < max width keep adding to the line, else make a new one
                if (dblXSize < sngMaxWidthInPoints)
                {
                    strGoodWidth = strTestString;
                }
                else
                {
                    if (linesAdded == 0)
                    {
                        strFinalString = strGoodWidth;
                    }
                    else
                    {
                        strFinalString = strFinalString + Environment.NewLine + strGoodWidth;
                    }
                    linesAdded   = linesAdded + 1;
                    strGoodWidth = varWordArray.GetValue(i).ToString();
                }
            }

            strFinalString = strFinalString + Environment.NewLine + strGoodWidth;
            pAppDisplay.FinishDrawing();

            return(strFinalString);
        }