Re: Dynamically create Drawing.Pens color?
- From: "Bob Powell [MVP]" <bob@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 12 Jun 2007 17:44:28 +0200
Try Int32.Parse or TryParse to convert from string to a 32 bit value and then use that in the FromArgb.
--
--
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting
http://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"NathanC" <NathanC@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:D99DA308-E1AF-4EB8-AF92-623675B86235@xxxxxxxxxxxxxxxx
Sorry - I thought I had included that in the previous posts:
dvGetSeatStatus returns multiple values from a web service- the two I am
using in this case are named 'fore_color' and 'back_color' - these values are
long RGB values (189500)
strFore = dvGetSeatStatus(0)("fore_color").ToString() - I was just hedging
my bets here when I first threw the code together. .ToString isn't required -
the values are already strings.
The fore_color and back_color values are to be used to color rectangles that
I am drawing. Each rectangle or 'seat' may have different fore_color and
back_color values, so instead of hardcoding the seat.DrawRectangle &
seat.FillRectangle color values (example:
seat.DrawRectangle(Drawing.Pens.White,etc...) I need to be able to define the
Drawing.Pen color value dynamically using the long RGB value.
Up to this point, I have not had sucess.
Hopefully that helps,
Thanks very much -
"Bob Powell [MVP]" wrote:
It's impossible to see whats going on here because we don't have all the
info.
#1 What type is the object in the dvGetSeatStatus array?
#2 Why convert tostring and then back to something else? Why not convert
straight to the type you need?
--
--
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting
http://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"NathanC" <NathanC@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:8E47A66B-8952-4B0A-8810-7A661AAF8441@xxxxxxxxxxxxxxxx
> Still not working - not sure why - this appears to be the thing to do.
>
> Dim strFore As String
> Dim strBack As String
>
> strFore = dvGetSeatStatus(0)("fore_color").ToString()
> strBack = dvGetSeatStatus(0)("back_color").ToString()
>
> seat.DrawRectangle(New
> Drawing.Pen(Drawing.Color.FromArgb(Convert.ToInt32(strFore))), (xpos -
> offset), (ypos), 10, 16)
>
> '-----------------------------------------------------
>
> I have also tried this:
> Dim fore_color = System.Drawing.Color
> Dim strFore As String
>
> strFore = dvGetSeatStatus(0)("fore_color").ToString()
> fore_color = Drawing.Color.FromArgb(strFore)
> seat.DrawRectangle(New Drawing.Pen(fore_color), (xpos - offset), > (ypos),
> 10,
> 16)
>
> I know that the FromArgb function is correctly converting the returned
> value
> from the web service into a useable color - because I am doing it
> elsewhere
> on the site.
>
> Thanks,
>
> "Jeff Johnson" wrote:
>
>>
>> "Jeff Johnson" <i.get@xxxxxxxxxxx> wrote in message
>> news:OFdcImpqHHA.3284@xxxxxxxxxxxxxxxxxxxxxxx
>>
>> > Or, since the poster appears to be using VB (unless he's just >> > dropping
>> > the
>> > semicolons in his sample code),
>> >
>> > Using pen As New Pen(fore_color)
>> > [...]
>> > End Using
>> > [...]
>>
>> Hmmm, I forgot VB was case sensitive (been writing too much C#). I'm >> not
>> positive if it will be happy using a class name as an identifier. >> Might
>> be
>> better to use
>>
>> Using borderPen As New Pen(fore_color)
>> [...]
>> End Using
>> [...]
>>
>>
>>
.
- Follow-Ups:
- Re: Dynamically create Drawing.Pens color?
- From: NathanC
- Re: Dynamically create Drawing.Pens color?
- References:
- Re: Dynamically create Drawing.Pens color?
- From: Jeff Johnson
- Re: Dynamically create Drawing.Pens color?
- From: Morten Wennevik [C# MVP]
- Re: Dynamically create Drawing.Pens color?
- From: Jeff Johnson
- Re: Dynamically create Drawing.Pens color?
- From: Jeff Johnson
- Re: Dynamically create Drawing.Pens color?
- From: Bob Powell [MVP]
- Re: Dynamically create Drawing.Pens color?
- From: NathanC
- Re: Dynamically create Drawing.Pens color?
- Prev by Date: Generic error on SelectActiveFrame()
- Next by Date: Re: Dynamically create Drawing.Pens color?
- Previous by thread: Re: Dynamically create Drawing.Pens color?
- Next by thread: Re: Dynamically create Drawing.Pens color?
- Index(es):
Relevant Pages
|