Hi,
I want to diplay a Multiline subject :
I used a customfilter to do that supplied earlier in this site.
How can i do that correctly ?
I want to apply a padding on the text displayed inside the appointment
Check the file result.png in the attached file to get an idea for the result i need.
thx
Hi Michel,
I'm not exactly sure what your question is. Your sample places multi-line text into the Subject of an appointment. The CreationFilter sizes the appointment element so it's big enough to fit the text. But this isn't working quite right because this code is not accounting for the borders, for one thing. And for another, it's using the exact size of the text as the size of the AppointmentUIElement. So you would need to add in some extra padding of whatever size you want. And also account for the borders of the subject, if there are any.
The code you have here looks to me like a quick sample someone threw together just to get you on the right track. This code is making a lot of assumptions. For example, it's assuming that the Subject is being drawn using the control's Font and not some other font assigned by an Appearance of via AppStylist. It also seems like it's making some assumptions about other appointments in the same day.
What you are trying to do here is very complicated. I'm not sure what the requirement are for your application or what assumptions you can make here about your application. If you have a specific question about one particular part of this, I can try to assist you, but I'm afraid writing fully-functional code that handles multi-line text in an appointment subject in all possible cases is beyond the scope of support. That would be a feature request.
Thx !
To maked simple;
I want to resize the Height of the Appointment BAR to Fit the Text in the Subject of the appointment.
check the image in the attached file
Each line is separated by LineFeed.
Okay... so what's the problem? The sample you attached here does that - doesn't it?
It doesn't do it very well, but that's for all the reasons I already listed above. You will need to deal with those issues in whatever way makes sense for your application based on whatever assumptions you can make in your application.
Thank you very much !
I took another look at your sample and I think I was confused. Your original post said
"I want to diplay a Multiline subject :
I used a customfilter to do that supplied earlier in this site."
So I assumed your sample was already doing this, but apparently, it's doing something else.
So I changed around the CreationFilter to more correctly size the AppointmentUIElement based on the text, accounting for the borders.
public void AfterCreateChildElements(UIElement parent) { if (parent is TextUIElement) { var textElement = (TextUIElement)parent;
if (textElHeight == -1) { textElHeight = textElement.Rect.Height; } var appointmentElement = textElement.GetAncestor(typeof(AppointmentUIElement)) as AppointmentUIElement;
if (appointmentElement == null || textElement.IsTextFullyVisible) return; SizeF size; using (Graphics g = textElement.Control.CreateGraphics()) { size = DrawUtility.MeasureString(g, textElement.Text, textElement.Control.Font); }
var borderWidths = DrawUtility.CalculateBorderWidths(appointmentElement.BorderStyle, appointmentElement.BorderSides); size.Width += borderWidths.Left + borderWidths.Right; size.Height += borderWidths.Top + borderWidths.Bottom;
int padding = 5; size.Width += padding; size.Height += padding;
appointmentElement.Rect = new Rectangle( appointmentElement.Rect.X, appointmentElement.Rect.X, (int)Math.Ceiling(size.Width), (int)Math.Ceiling(size.Height) );
textElement.Rect = appointmentElement.Rect; textElement.WrapText = true; textElement.MultiLine = true; } }
But as I mentioned early, what you are trying to do here is incredibly complex and difficult and this code is not going to work right. Already I can see a problem in your sample that the appointment on the bottom is running outside the borders of the owner. So that's an issue you would have to deal with and that's going to be very difficult. And this sample doesn't even have any adjacent or overlapping appointments, so that's going to make it even more complicated.
Frankly, even for someone who is intimately familiar with CreationFilters and UIElements, it would require a huge amount of time and effort to achieve what you want here.
Can you fix the problem in my example i sent you in the 1st post ?
it should help me a lot . to undersdand it correctly ;
best regards.