473,394 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Brush Constructor Question

I've got an inherited control where I want the user to be able to specify a
color property. Using that color, I'm drawing a line

private m_UserDefinedColor as Color

.....

Dim g as Graphics=this.CreateGraphics
Dim myPen as Pen = new Pen(m_UserDefinedColor)
g.DrawLine(myPen, X1, Y, X2 - 1, Y)

Then I want to draw a triangle filled with the same color. I set the point
and do:

g.FillPolygon(Brushes.Red, leftTriangle);

Because I can't figure out how to create a Brush that has the userdefined
color.

It's not possible to do: myBrush as Brush = new Brush(m_UserDefinedColor)

How do you specify the Brush Color in this case?

Cheers,

Johnny J.
Sep 10 '07 #1
2 1518
On Sep 10, 11:40 am, "Johnny J." <j...@altcom.sewrote:
I've got an inherited control where I want the user to be able to specify a
color property. Using that color, I'm drawing a line

private m_UserDefinedColor as Color

....

Dim g as Graphics=this.CreateGraphics
Dim myPen as Pen = new Pen(m_UserDefinedColor)
g.DrawLine(myPen, X1, Y, X2 - 1, Y)

Then I want to draw a triangle filled with the same color. I set the point
and do:

g.FillPolygon(Brushes.Red, leftTriangle);

Because I can't figure out how to create a Brush that has the userdefined
color.

It's not possible to do: myBrush as Brush = new Brush(m_UserDefinedColor)

How do you specify the Brush Color in this case?

Cheers,

Johnny J.
IIRC you have to use one of the "other" brush objects (Solid,
Gradient, etc)

Something like:

Dim b As Brush = New SolidBrush(m_UserDefinedColor)

Thanks,

Seth Rowe

Sep 10 '07 #2
Thanks Seth

That solved the problem.

Cheers,
Johnny J.

"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11**********************@57g2000hsv.googlegro ups.com...
On Sep 10, 11:40 am, "Johnny J." <j...@altcom.sewrote:
>I've got an inherited control where I want the user to be able to specify
a
color property. Using that color, I'm drawing a line

private m_UserDefinedColor as Color

....

Dim g as Graphics=this.CreateGraphics
Dim myPen as Pen = new Pen(m_UserDefinedColor)
g.DrawLine(myPen, X1, Y, X2 - 1, Y)

Then I want to draw a triangle filled with the same color. I set the
point
and do:

g.FillPolygon(Brushes.Red, leftTriangle);

Because I can't figure out how to create a Brush that has the userdefined
color.

It's not possible to do: myBrush as Brush = new Brush(m_UserDefinedColor)

How do you specify the Brush Color in this case?

Cheers,

Johnny J.

IIRC you have to use one of the "other" brush objects (Solid,
Gradient, etc)

Something like:

Dim b As Brush = New SolidBrush(m_UserDefinedColor)

Thanks,

Seth Rowe

Sep 11 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rene | last post by:
I would like to get a reference to a Brush using the color name of the brush. For example, right now if I want a brush with a certain color, I would hard code something like Brushes.PeachPuff, this...
1
by: Serdar YILMAZ | last post by:
2
by: boxim | last post by:
having a moment, cant you just Brush br = new Brush(Color.Black);??? saying you cant cos it's an abstract class need to get to a brush from a color tia sam martin
45
by: Ben Blank | last post by:
I'm writing a family of classes which all inherit most of their methods and code (including constructors) from a single base class. When attempting to instance one of the derived classes using...
3
by: jcrouse | last post by:
I have the following string: e.Graphics.DrawString(Label5.Text, lblP1B1.Font, Brushes.White, -y, 0) I want to use the property label.forecolor for my text color. How do I get whats in...
5
by: Dennis | last post by:
When I instantiate a Brush resource such as a solidbrush, do I need to dispose the resource when I'm finished or will it automatically be disposed when the function/sub it's used in ends? Thank...
1
by: =?Utf-8?B?UEtsZW1t?= | last post by:
how to serialize a brush object with the XmlSerializer without knowing the brush type?
0
by: steve | last post by:
When drawing with a hatch brush with a statement such as myGraphics.FillPolygon(hatchBrush, polygon.vertices); the hatch brush is always oriented in the same direction. Is there a way of...
31
by: Tom P. | last post by:
I am doing quite a bit of custom painting and it means I have to create a lot of brushes (think one for every file system object in a directory) per paint. How expensive is this? Should I find a...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.