Пример #1
0
        //draws the main atom symbol, or an ellipse if necessary
        private AtomTextMetrics DrawSelf(DrawingContext drawingContext, bool measureOnly = false)
        {
            if (AtomSymbol != "")
            {
                var symbolText = new GlyphText(AtomSymbol, SymbolTypeface, SymbolSize, PixelsPerDip());
                symbolText.Fill = Fill;
                symbolText.MeasureAtCenter(Position);
                if (!measureOnly)
                {
                    symbolText.DrawAtBottomLeft(symbolText.TextMetrics.BoundingBox.BottomLeft, drawingContext);
                }

                return(symbolText.TextMetrics);
            }
            else
            {
                //so draw a circle
                double radiusX = SymbolSize / 3;

                Rect boundingBox = new Rect(new Point(Position.X - radiusX, Position.Y - radiusX),
                                            new Point(Position.X + radiusX, Position.Y + radiusX));
                return(new AtomTextMetrics
                {
                    BoundingBox = boundingBox,
                    Geocenter = Position,
                    TotalBoundingBox = boundingBox,
                    FlattenedPath = new List <Point>
                    {
                        boundingBox.BottomLeft, boundingBox.TopLeft, boundingBox.TopRight, boundingBox.BottomRight
                    }
                });
            }
        }
Пример #2
0
 /// <summary>
 /// Draws the subscripted group text
 /// </summary>
 /// <param name="drawingContext">DC supplied by OnRender</param>
 /// <param name="measure">Provided by calling the Measure method previously</param>
 /// <param name="pixelsPerDip"></param>
 /// <param name="fill"></param>
 public void DrawSelf(DrawingContext drawingContext, AtomTextMetrics measure, float pixelsPerDip, Brush fill)
 {
     _mainText.Fill = fill;
     _mainText.DrawAtBottomLeft(measure.BoundingBox.BottomLeft, drawingContext);
     if (_subText != null)
     {
         _subText.Fill = fill;
         _subText.DrawAtBottomLeft(_subText.TextMetrics.BoundingBox.BottomLeft, drawingContext);
     }
 }