Rank: Member Groups: Member
Joined: 11/6/2007 Posts: 10 Points: 15
|
Hi, I want to get the font size of the resized TextVobject? I was try with following code, but it still get the font size before TextVobject resize.
If TypeOf obj Is Aurigma.GraphicsMill.WinControls.TextVObject Then Dim txtObj As Aurigma.GraphicsMill.WinControls.TextVObject = CType(obj, Aurigma.GraphicsMill.WinControls.TextVObject) MsgBox (txtObj.Font.Size) End If
Thanks in advance.
|
Rank: Advanced Member Groups: Administration
, Member
Joined: 1/31/2005 Posts: 386 Points: 403
|
Hello, TextObject resize doesn't affect on the FontSize directly. It just changes VObject transformation matrix, therefore you should calculate scale coefficient and multiply it with TextObject.Font.Size value. Here is code sample to illustrate the idea: Code:
private static float CalcDistance(System.Drawing.PointF p0,
System.Drawing.PointF p1)
{
float dx = p0.X - p1.X;
float dy = p0.Y - p1.Y;
return (float)Math.Sqrt(dx * dx + dy * dy);
}
private static float GetVerticalScale(
Aurigma.GraphicsMill.WinControls.IVObject obj)
{
System.Drawing.PointF[] pnts = new System.Drawing.PointF[] {
new System.Drawing.PointF(0, 0),
new System.Drawing.PointF(0, 1)};
obj.Transform.TransformPoints(pnts);
return CalcDistance(pnts[0], pnts[1]);
}
private void TestTextFontSize()
{
Aurigma.GraphicsMill.WinControls.TextVObject textObj =
<... get object from somewhere... >;
System.Windows.Forms.MessageBox.Show(
(textObj.Font.Size * GetVerticalScale(textObj)).ToString());
}
Best wishes, Alex.
|