In reading about ICondition it only talks about situations where something does not "fit on a page".
I have a report where I'm trying to make sure that the contents of a container fits within a cell in a fixed height table. The cell allows me to add an ICondition interface item but ( as near as I can tell) the ICondition does now work ... or more likely I don't have a clue as to what I'm doing or how it should work in this case.
My expectation was that the ICondition would use the "false" condition if the contents of the container would not fit in the space left in the fixed size cell. If it does not work this way, is there any way within the documents engine where I can have a table, add a set of rows and then get the amount of space left in the table?
The problem I'm trying to solve is that I have a fixed area into which I need to put some unknown amount of text. What I need to be able to do is figure out how much space is left in a table cell and scale the text font until it fits ... of is below some minimum readable limit.
Is there any way to accomplish this?
ThanksNeil
Neil,
I don't think that a condition will help you with this situation because it basically only gives you 2 options - one if the content fits and the other if the content doesn't fit - so there would be no guarantee that either solution would fit the size available to you. I think that your best option here would be to measure the text yourself to see if it will fit the content of the area available to you and if it doesn't fit, resize the content accordingly. You should be able to use the Graphics.MeasureString method; if you have access to an IGraphics object (i.e. a canvas), you could use the MeasureString as-is, otherwise when you create the .NET Graphics object, keep in mind that the Documents engine measures in Points, not Pixels. There is a static method Infragistics.Documents.Utils.Converter.PixelsToPoints that should help you here, though you might be able to set the PageUnit to Point on the graphics object, but I'm unsure off the top of my head if this is the correct property; set whichever property has to do with units on the graphics object to Point
As for your question about figuring out how much space is left, this available while building the report because none of the objects are measured until the report is actually generated.
-Matt
Matt,
Thanks for the resonse. It sounds like I'm stuck if I want to use the Document Reports Engine. If I can't figure out how much space is left/available then being able to measure the text is more or less useless. Or am I still missing something?
Well, that is my problem. The table is fixed height but the size of the last cell is dependent on how much is placed in rows above. So the last cell is set to AutoHeight and has to be that way.
It would be nice that if (at report generation time) there was some way to get the "position" of an element. other than that, my only chance (it appears) is to try to keep a running total of all text entered above the cell I care about.
You should have the height of the cell or row of the table available to you, unless it is set to the default AutoHeight, but it doesn't seem like this is the case. Assuming that you have a height of type FixedHeight, you should be able to get the height and perform your measurements accordingly.
Sorry, I guess I was not clear.
By "Unknown" I mean at design time. At run time I get the text to fill the cell. The Table has a fixed size and has one or more rows or information above the last row in the table. The row has only one cell that I need to fill with the text that I get from a business object at run time.
In this case, the enclosing table can not increase in total height (by requirement) and so in order to figure out a font size to use for the text in this last cell I have to know 2 things. 1) The height of the text block (which I can calculate at report creating time given the text from the business object and the grapics object as you described and the width of the cell) and 2) the height of the cell which sounds like it is not available. Without the latter, I'm not sure how do what I need to do.
You say that you want to know how much space is left in the cell; what else have you put into it? The way I read your original description, it sounded like you knew what you were putting into the cell, though I'm not sure exactly what you meant by an 'unknown' amount of text (I interpreted this as you will know at run-time on a per-cell basis). If you're only putting text into the cell, and the cell's width and height are static, what is the additional limitation preventing you from measuring the text?