dotgnu-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [DotGNU]The new controls (was: Phoenix)


From: Neil Cawse
Subject: RE: [DotGNU]The new controls (was: Phoenix)
Date: Mon, 28 Jul 2003 22:40:58 -0400

>Yeah.. I'm thinking the word wrapping code needs to be reusable somehow tho, because MANY controls require > it, and it'd be kind of pointless, to recode every control to render the alignments and word wrapping individually.  > For example, StatusBarPanel requires word wrapping and alignments, so does label, so does checkbox,
> radiobutton, etc etc.  Theres got to be a way we could add a method somewhere that we could throw it a x,y,x,y > or rectangle, StringAlign and LineAlign and string and font params and color, and it would do it for us, so we
> could reuse it in any control we require.
>
> What do you think?  I just find it not very efficient to redo it in every control.
 
ok what im getting at:
the extact method you are looking for is DrawString.
you are correct we must reuse, to do that use DrawString, all the wrapping is handled. If you call DrawString, it will wrap the text according to stringAlignment and lineAlignment BUT its not fully implemented yet. MeasureCharacterRanges is - which is what i use for the textbox to get the positions, i then draw each character. What i will do is make sure that DrawString renders like MeasureCharacterRanges. This is a snippet of code to give you the idea:
 

// Convert control settings to a StringFormat

StringFormat format = new StringFormat();

if (RightToLeft == RightToLeft.Yes)

  format.FormatFlags |= StringFormatFlags.DirectionRightToLeft;

if (!Multiline)

  format.FormatFlags |= StringFormatFlags.NoWrap;

if (textAlign == HorizontalAlignment.Left)

  format.Alignment = StringAlignment.Near;

else if (textAlign == HorizontalAlignment.Right)

  format.Alignment = StringAlignment.Far;

else if (textAlign == HorizontalAlignment.Center)

  format.Alignment = StringAlignment.Center;

g.DrawString(Text, Font, bounds, format)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]