Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Microsoft .Net & .Net Compact Framework
 QCChart2D and QCChart2D CF (VB and C#)
 Label/Text bounding box question
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

pmcconaghy

2 Posts

Posted - 20 Feb 2004 :  06:56:05  Show Profile  Reply with Quote
Is it possible to obtain the size of a piece of text in "Working Coordinates"?

I don't want to scale my label font size and so when the graph is enlarged I'd like to be able to keep it the same physical distance from the border.

To do this... I need to call "SetGraphBorderDiagonal" in the OnResize event for the form. But... I need to know how big the text label is.

Any ideas?

Regards
peter

quinncurtis

1164 Posts

Posted - 20 Feb 2004 :  10:48:42  Show Profile  Reply with Quote
The SetGraphBorder... functions work in Normalized Graph Coordinates (0.0 to 1.0), not Working Coordinates, which are the same as the scale used for the axes.

The Device (or pixel) Coordinate bounds of a text object can be retrieved (AFTER the object is drawn) using the text objects BoundingBox property. The device coordinates can be converted to normalized graph coordinates using the PhysicalCoordinates.ConvertDimension method.

Dimension textdevdim =
new Dimension(yAxisLab1.BoundingBox.Width, yAxisLab1.BoundingBox.Height);

Dimension textnormdim =
pTransform1.ConvertDimension(ChartObj.NORM_GRAPH_POS, textdevdim, ChartObj.DEV_POS);

double textnormwidth = textnormdim.Width;


Or you can just get the text objects bounding box width, and divide it by the ChartView width.

double textdevwidth = yAxisLab1.BoundingBox.Width;
double textnormwidth = textdevwidth / chartVu.Width;

The results should be the same, give or take some rounding error.



Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-07 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07