0

たとえば、私のフォーマットされたテキストは

 var formattedtext=new FormattedText("some string", CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, this.GetTypeface(), 12.0, Brushes.Black);

書式設定されたテキストを垂直方向の中央揃えで特定の四角形領域に揃える必要があります。

4

2 に答える 2

0

次のようなことを試すことができます:

// e is the PaintEventArgs, which is passed as a parameter

// construct a new Rectangle .
Rectangle  displayRectangle = 
    new Rectangle (new Point(40, 40), new Size (80, 80));

// construct new StringFormat object
var format = new StringFormat(StringFormatFlags.DirectionVertical);

// set the LineAlignment and Alignment properties for 
format.LineAlignment = StringAlignment.Near;
format.Alignment = StringAlignment.Center;

// draw the bounding rectangle and a string for the StringFormat object.
e.Graphics.DrawRectangle(Pens.Black, displayRectangle);
e.Graphics.DrawString("Showing Format", this.Font, 
    Brushes.Red, (RectangleF)displayRectangle, format);
于 2015-01-23T07:51:23.353 に答える