PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework Bordered Text

Reply

Bordered Text

 
Thread Tools Rate Thread
Old 14-04-2008, 04:14 PM   #1
andrerus@gmail.com
Guest
 
Posts: n/a
Default Bordered Text


Hi, does anybody know a way to draw a bordered text (which each
character surrounded by a contour)?

Andrea
  Reply With Quote
Old 14-04-2008, 04:33 PM   #2
Fabien
Guest
 
Posts: n/a
Default Re: Bordered Text

Hi,

You have to create your own component inherits from label and override
the OnPaint method.

BR

Fabien Decret (Device Application Development MVP)
Windows Embedded Consultant

ADENEO (ADESET)
http://www.adeneo.adetelgroup.com/ | http://fabdecret.blogspot.com/


On 14 avr, 17:14, andre...@gmail.com wrote:
> Hi, does anybody know a way to draw a bordered text (which each
> character surrounded by a contour)?
>
> Andrea


  Reply With Quote
Old 14-04-2008, 05:19 PM   #3
andrerus@gmail.com
Guest
 
Posts: n/a
Default Re: Bordered Text

On 14 Apr, 17:33, Fabien <fab_00_2...@msn.com> wrote:
> Hi,
>
> You have to create your own component inherits from label and override
> the OnPaint method.
>
> BR
>
> Fabien Decret (Device Application Development MVP)
> Windows Embedded Consultant
>
> ADENEO (ADESET)http://www.adeneo.adetelgroup.com/|http://fabdecret.blogspot.com/
>
> On 14 avr, 17:14, andre...@gmail.com wrote:
>
> > Hi, does anybody know a way to draw a bordered text (which each
> > character surrounded by a contour)?

>
> > Andrea


Well, but my question is a bit more technical:
To paint a string I usually use the Graphics.DrawString method,
If I use a traditional font, I'll obtain a full filled text (without
contour)
If I use a bordered font, I'll obtain an empty text (with the only
contour painted).
I thought to a rough solution "paint a first filled string and over it
the same string using a bordered font", but if fonts are different
I'll obtain an illegible text.
So there is any other solution to easy paint a string (or a single
char) with a specified fill color and a different border color?

Thanks.

Andrea
  Reply With Quote
Old 14-04-2008, 06:46 PM   #4
dbgrick
Guest
 
Posts: n/a
Default Re: Bordered Text

Per Fabien's recommendation, create a control and inherit from Control or
Label, override the OnPaint method and then do the drawing yourself. Here is
an example:

protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;

Rectange currentRectangle = new Rectangle(0, 0. base.Width, base.Height);

g.FillRectangle(new SolidBrush(base.BackColor), currentRectangle);

g.DrawString(base.Text, base.Font, 3f, ((float)base.Height -
stringSize.Height) / 2f);

currentRectangle = new Rectangle(1, 1. base.Width - 2, base.Height - 2);

g.DrawRectangle(new Pen(Color.Black, 1f), currentRectangle);
}

And you've drawn a label with a border.

Regards,
Rick D.

"andrerus@gmail.com" wrote:

> On 14 Apr, 17:33, Fabien <fab_00_2...@msn.com> wrote:
> > Hi,
> >
> > You have to create your own component inherits from label and override
> > the OnPaint method.
> >
> > BR
> >
> > Fabien Decret (Device Application Development MVP)
> > Windows Embedded Consultant
> >
> > ADENEO (ADESET)http://www.adeneo.adetelgroup.com/|http://fabdecret.blogspot.com/
> >
> > On 14 avr, 17:14, andre...@gmail.com wrote:
> >
> > > Hi, does anybody know a way to draw a bordered text (which each
> > > character surrounded by a contour)?

> >
> > > Andrea

>
> Well, but my question is a bit more technical:
> To paint a string I usually use the Graphics.DrawString method,
> If I use a traditional font, I'll obtain a full filled text (without
> contour)
> If I use a bordered font, I'll obtain an empty text (with the only
> contour painted).
> I thought to a rough solution "paint a first filled string and over it
> the same string using a bordered font", but if fonts are different
> I'll obtain an illegible text.
> So there is any other solution to easy paint a string (or a single
> char) with a specified fill color and a different border color?
>
> Thanks.
>
> Andrea
>

  Reply With Quote
Old 15-04-2008, 05:44 PM   #5
andrerus@gmail.com
Guest
 
Posts: n/a
Default Re: Bordered Text

On 14 Apr, 19:46, dbgrick <dbgr...@discussions.microsoft.com> wrote:
> Per Fabien's recommendation, create a control and inherit from Control or
> Label, override the OnPaint method and then do the drawing yourself. Here is
> an example:
>
> protected override void OnPaint(PaintEventArgs e)
> {
> Graphics g = e.Graphics;
>
> Rectange currentRectangle = new Rectangle(0, 0. base.Width, base.Height);
>
> g.FillRectangle(new SolidBrush(base.BackColor), currentRectangle);
>
> g.DrawString(base.Text, base.Font, 3f, ((float)base.Height -
> stringSize.Height) / 2f);
>
> currentRectangle = new Rectangle(1, 1. base.Width - 2, base.Height - 2);
>
> g.DrawRectangle(new Pen(Color.Black, 1f), currentRectangle);
>
> }
>
> And you've drawn a label with a border.
>
> Regards,
> Rick D.
>
> "andre...@gmail.com" wrote:
> > On 14 Apr, 17:33, Fabien <fab_00_2...@msn.com> wrote:
> > > Hi,

>
> > > You have to create your own component inherits from label and override
> > > the OnPaint method.

>
> > > BR

>
> > > Fabien Decret (Device Application Development MVP)
> > > Windows Embedded Consultant

>
> > > ADENEO (ADESET)http://www.adeneo.adetelgroup.com/|http://fabdecret.blogspot.com/

>
> > > On 14 avr, 17:14, andre...@gmail.com wrote:

>
> > > > Hi, does anybody know a way to draw a bordered text (which each
> > > > character surrounded by a contour)?

>
> > > > Andrea

>
> > Well, but my question is a bit more technical:
> > To paint a string I usually use the Graphics.DrawString method,
> > If I use a traditional font, I'll obtain a full filled text (without
> > contour)
> > If I use a bordered font, I'll obtain an empty text (with the only
> > contour painted).
> > I thought to a rough solution "paint a first filled string and over it
> > the same string using a bordered font", but if fonts are different
> > I'll obtain an illegible text.
> > So there is any other solution to easy paint a string (or a single
> > char) with a specified fill color and a different border color?

>
> > Thanks.

>
> > Andrea


I haven't tested it, but reading the code what it seems to produce is
a string inside a rectangle, isn't it? What I want is instead a string
in which each character is surrounded by a contour that follows its
shape (not a rectangle).

Thanks,
Andrea
  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off