473,657 Members | 2,996 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Polygons in VS8?

Are polygonal buttons or perhaps polygons with tooltips and and click events
available in VS8 or is it too early yet?

Thanks in advance...

--
Timothy Casey GPEMC! >11950 is the nu****@fieldcra ft.com.au 2email
Terms & conditions apply. See www.fieldcraft.biz/GPEMC
Discover valid interoperable web menus, IE security, TSR Control,
& the most advanced speed reading application @ www.fieldcraft.biz
Jun 19 '07 #1
6 1374
On Jun 19, 3:36 am, "Number 11950 - GPEMC! Replace number with 11950"
<num...@fieldcr aft.bizwrote:
Are polygonal buttons or perhaps polygons with tooltips and and click events
available in VS8 or is it too early yet?

Thanks in advance...

--
Timothy Casey GPEMC! >11950 is the num...@fieldcra ft.com.au 2email
Terms & conditions apply. Seewww.fieldcra ft.biz/GPEMC
Discover valid interoperable web menus, IE security, TSR Control,
& the most advanced speed reading application @www.fieldcraft .biz
You can assign a polygonal region to a button to change its shape, so
in a sense, yes they do exist.

Chris

Jun 19 '07 #2

"Chris Dunaway" <du******@gmail .comwrote in message
news:11******** *************@q 75g2000hsh.goog legroups.com...
On Jun 19, 3:36 am, "Number 11950 - GPEMC! Replace number with 11950"
<num...@fieldcr aft.bizwrote:
Are polygonal buttons or perhaps polygons with tooltips and and click
events
available in VS8 or is it too early yet?

Thanks in advance...

--
Timothy Casey GPEMC! >11950 is the num...@fieldcra ft.com.au 2email
Terms & conditions apply. Seewww.fieldcra ft.biz/GPEMC
Discover valid interoperable web menus, IE security, TSR Control,
& the most advanced speed reading application @www.fieldcraft .biz

You can assign a polygonal region to a button to change its shape, so
in a sense, yes they do exist.

Chris
So is there a relatively simple way to display an interlocking grid of
polygons (eg hexagons), each with its own tooltip and click response?

Thanks in Advance...

--
Timothy Casey GPEMC! >11950 is the nu****@fieldcra ft.com.au 2email
Terms & conditions apply. See www.fieldcraft.biz/GPEMC
Discover valid interoperable web menus, IE security, TSR Control,
& the most advanced speed reading application @ www.fieldcraft.biz
Jun 19 '07 #3
On Jun 19, 8:49 am, "Number 11950 - GPEMC! Replace number with 11950"
<num...@fieldcr aft.bizwrote:
"Chris Dunaway" <dunaw...@gmail .comwrote in message

news:11******** *************@q 75g2000hsh.goog legroups.com...
On Jun 19, 3:36 am, "Number 11950 - GPEMC! Replace number with 11950"
<num...@fieldcr aft.bizwrote:
Are polygonal buttons or perhaps polygons with tooltips and and click
events
available in VS8 or is it too early yet?
Thanks in advance...
--
Timothy Casey GPEMC! >11950 is the num...@fieldcra ft.com.au 2email
Terms & conditions apply. Seewww.fieldcra ft.biz/GPEMC
Discover valid interoperable web menus, IE security, TSR Control,
& the most advanced speed reading application @www.fieldcraft .biz
You can assign a polygonal region to a button to change its shape, so
in a sense, yes they do exist.
Chris

So is there a relatively simple way to display an interlocking grid of
polygons (eg hexagons), each with its own tooltip and click response?

Thanks in Advance...

--
Timothy Casey GPEMC! >11950 is the num...@fieldcra ft.com.au 2email
Terms & conditions apply. Seewww.fieldcra ft.biz/GPEMC
Discover valid interoperable web menus, IE security, TSR Control,
& the most advanced speed reading application @www.fieldcraft .biz
I don't know how simple it is. Here is a basic class that changes the
region of a button to a hexagon shape. The values that are used for
the points array are hardcoded for a button that is 40 x 40 pixels.

To refine this class, you would have to add code to paint the button
appropriately, override the OnResize event so that you can change the
region when the button changes size, etc.

Hope this gives you some ideas

Chris

Public Class HexButton
Inherits Button

Private _bRegionSet As Boolean = False

Public Sub New()

End Sub

Protected Overrides Sub OnPaint(ByVal pevent As
System.Windows. Forms.PaintEven tArgs)

If Not _bRegionSet Then
setRegion()
_bRegionSet = True
End If

'pevent.Graphic s.FillRegion(Br ushes.Blue, Me.Region)

MyBase.OnPaint( pevent)
End Sub

Private Sub setRegion()
Dim gp As New Drawing2D.Graph icsPath()

Dim hexPoints As PointF() = _
{New PointF(17.3, 0), _
New PointF(34.6, 10), _
New PointF(34.6, 30), _
New PointF(17.3, 40), _
New PointF(0, 30), _
New PointF(0, 10)}

gp.AddPolygon(h exPoints)
gp.CloseFigure( )

Dim rgn As New Region(gp)

Me.Region = rgn

rgn.Dispose()
gp.Dispose()
End Sub

End Class

Jun 19 '07 #4
On Jun 19, 4:51 pm, Chris Dunaway <dunaw...@gmail .comwrote:
On Jun 19, 8:49 am, "Number 11950 - GPEMC! Replace number with 11950"

<num...@fieldcr aft.bizwrote:
"Chris Dunaway" <dunaw...@gmail .comwrote in message
news:11******** *************@q 75g2000hsh.goog legroups.com...
On Jun 19, 3:36 am, "Number 11950 - GPEMC! Replace number with 11950"
<num...@fieldcr aft.bizwrote:
Are polygonal buttons or perhaps polygons with tooltips and and click
events
available in VS8 or is it too early yet?
Thanks in advance...
--
Timothy Casey GPEMC! >11950 is the num...@fieldcra ft.com.au 2email
Terms & conditions apply. Seewww.fieldcra ft.biz/GPEMC
Discover valid interoperable web menus, IE security, TSR Control,
& the most advanced speed reading application @www.fieldcraft .biz
You can assign a polygonal region to a button to change its shape, so
in a sense, yes they do exist.
Chris
So is there a relatively simple way to display an interlocking grid of
polygons (eg hexagons), each with its own tooltip and click response?
Thanks in Advance...
--
Timothy Casey GPEMC! >11950 is the num...@fieldcra ft.com.au 2email
Terms & conditions apply. Seewww.fieldcra ft.biz/GPEMC
Discover valid interoperable web menus, IE security, TSR Control,
& the most advanced speed reading application @www.fieldcraft .biz

I don't know how simple it is. Here is a basic class that changes the
region of a button to a hexagon shape. The values that are used for
the points array are hardcoded for a button that is 40 x 40 pixels.

To refine this class, you would have to add code to paint the button
appropriately, override the OnResize event so that you can change the
region when the button changes size, etc.

Hope this gives you some ideas

Chris

Public Class HexButton
Inherits Button

Private _bRegionSet As Boolean = False

Public Sub New()

End Sub

Protected Overrides Sub OnPaint(ByVal pevent As
System.Windows. Forms.PaintEven tArgs)

If Not _bRegionSet Then
setRegion()
_bRegionSet = True
End If

'pevent.Graphic s.FillRegion(Br ushes.Blue, Me.Region)

MyBase.OnPaint( pevent)
End Sub

Private Sub setRegion()
Dim gp As New Drawing2D.Graph icsPath()

Dim hexPoints As PointF() = _
{New PointF(17.3, 0), _
New PointF(34.6, 10), _
New PointF(34.6, 30), _
New PointF(17.3, 40), _
New PointF(0, 30), _
New PointF(0, 10)}

gp.AddPolygon(h exPoints)
gp.CloseFigure( )

Dim rgn As New Region(gp)

Me.Region = rgn

rgn.Dispose()
gp.Dispose()
End Sub

End Class
Here's a little bit better class that at least allows for resizing.
You still will have to adjust the painting to customize its look.
Also, there is no visual indication when the button is clicked. You
will have to do that as well. Watch for typos.

Chris
'**** BEGIN CODE HERE
Imports System.Drawing. Drawing2D

Public Class HexButton
Inherits Button

'Set the styles so we can control the painting
Public Sub New()
Me.SetStyle(Con trolStyles.AllP aintingInWmPain t Or _
ControlStyles.U serPaint Or _
ControlStyles.O ptimizedDoubleB uffer, True)
End Sub

'Paint the button
Protected Overrides Sub OnPaint(ByVal pevent As
System.Windows. Forms.PaintEven tArgs)

'First set the region
If Me.Region Is Nothing Then
setRegion()
End If

'Get the points that correspond to our hex shape
'These are the same points used to create the region
Dim hexPoints As PointF() = getHexPoints()

'Create a GraphicsPath
Using gp As GraphicsPath = getPath(hexPoin ts)
'Create a Pen to draw with
Using p As New Pen(Color.Red, 5)

'Draw the background of the button
pevent.Graphics .FillPath(Brush es.Blue, gp)

'Draw the outline of the button
pevent.Graphics .DrawPolygon(p, hexPoints)

'Draw the text for the button
Dim sf As New StringFormat

sf.Alignment = StringAlignment .Center
sf.LineAlignmen t = StringAlignment .Center
sf.Trimming = StringTrimming. Word

Dim rc As New RectangleConver ter

pevent.Graphics .DrawString(Me. Text, Me.Font,
Brushes.White, Me.ClientRectan gle, sf)
End Using
End Using

End Sub

'When the button is resized, it makes sure the button is a square
in shape and sets the new region
Protected Overrides Sub OnResize(ByVal e As System.EventArg s)
Me.Height = Me.Width
setRegion()
End Sub

'Sets the button's region. Disposing of any existing region
Private Sub setRegion()

'Get the button's current region, if any
Dim tmpRegion As Region = Me.Region

'Set the button's new region
Me.Region = getRegion()

'Dispose of the old region
If tmpRegion IsNot Nothing Then
tmpRegion.Dispo se()
End If
End Sub

'Creates a Region object from a GraphicsPath
Private Function getRegion() As Region
Dim rgn As Region = Nothing

Using gp As GraphicsPath = getPath()
rgn = New Region(gp)
End Using

Return rgn
End Function

Private Function getRegion(ByVal gp As GraphicsPath) As Region
Return New Region(gp)
End Function

'Creates a GraphicsPath object from an array of points
Private Function getPath() As GraphicsPath
Dim gp As New GraphicsPath()
gp.AddPolygon(g etHexPoints())
gp.CloseFigure( )
Return gp
End Function

Private Function getPath(ByVal hexPoints As PointF()) As
GraphicsPath
Dim gp As New GraphicsPath()
gp.AddPolygon(h exPoints)
gp.CloseFigure( )
Return gp
End Function

'Uses the button's width, to calculate the points needed for the
hex shape
Private Function getHexPoints() As PointF()
Dim d As Single

d = CSng((Me.Width * Math.Sqrt(3)) / 4)

Dim hexPoints As PointF() = _
{New PointF(CSng(Me. Width / 2), 0), _
New PointF(CSng(Me. Width / 2) + d, CSng(Me.Width / 4)), _
New PointF(CSng(Me. Width / 2) + d, CSng(3 * (Me.Width /
4))), _
New PointF(CSng(Me. Width / 2), Me.Width), _
New PointF(CSng(Me. Width / 2) - d, CSng(3 * (Me.Width /
4))), _
New PointF(CSng(Me. Width / 2) - d, CSng(Me.Width / 4))}

Return hexPoints
End Function

End Class

Jun 20 '07 #5
On Jun 20, 12:41 pm, Chris Dunaway <dunaw...@gmail .comwrote:
On Jun 19, 4:51 pm, Chris Dunaway <dunaw...@gmail .comwrote:
<snip>

Ok, I couldn't leave well enough alone. I changed it again, so that
you can set the backcolor, forecolor and I added properties for
BorderColor and BorderWidth.

Chris

Imports System.Drawing. Drawing2D

Public Class HexButton
Inherits Button

Public Sub New()
Me.SetStyle(Con trolStyles.AllP aintingInWmPain t Or _
ControlStyles.U serPaint Or _
ControlStyles.O ptimizedDoubleB uffer, True)

_borderColor = Me.ForeColor
_borderWidth = 3
End Sub

Protected Overrides Sub OnPaint(ByVal pevent As
System.Windows. Forms.PaintEven tArgs)

If Me.Region Is Nothing Then
setRegion()
End If

Dim hexPoints As PointF() = getHexPoints()

Using gp As GraphicsPath = getPath(hexPoin ts)
Using p As New Pen(Me.BorderCo lor, Me.BorderWidth)

Using br As New SolidBrush(Me.B ackColor)
pevent.Graphics .FillPath(br, gp)
End Using

pevent.Graphics .DrawPolygon(p, hexPoints)

Dim sf As New StringFormat

sf.Alignment = StringAlignment .Center
sf.LineAlignmen t = StringAlignment .Center
sf.Trimming = StringTrimming. Word

Dim rc As New RectangleConver ter

Using br As New SolidBrush(Me.F oreColor)
pevent.Graphics .DrawString(Me. Text, Me.Font, br,
Me.ClientRectan gle, sf)
End Using
End Using
End Using

End Sub

Private _borderWidth As Single
Public Property BorderWidth() As Single
Get
Return _borderWidth
End Get
Set(ByVal value As Single)
If value <_borderWidth Then
_borderWidth = value
Me.Refresh()
End If
End Set
End Property

Private _borderColor As Color
Public Property BorderColor() As Color
Get
Return _borderColor
End Get
Set(ByVal value As Color)
If value <_borderColor Then
_borderColor = value
Me.Refresh()
End If
End Set
End Property

Protected Overrides Sub OnResize(ByVal e As System.EventArg s)
Me.Height = Me.Width
setRegion()
End Sub

Private Sub setRegion()
Dim tmpRegion As Region = Me.Region
Me.Region = getRegion()

If tmpRegion IsNot Nothing Then
tmpRegion.Dispo se()
End If
End Sub

Private Function getRegion() As Region
Dim rgn As Region = Nothing

Using gp As GraphicsPath = getPath()
rgn = New Region(gp)
End Using

Return rgn
End Function

Private Function getRegion(ByVal gp As GraphicsPath) As Region
Return New Region(gp)
End Function

Private Function getPath() As GraphicsPath
Dim gp As New GraphicsPath()
gp.AddPolygon(g etHexPoints())
gp.CloseFigure( )
Return gp
End Function

Private Function getPath(ByVal hexPoints As PointF()) As
GraphicsPath
Dim gp As New GraphicsPath()
gp.AddPolygon(h exPoints)
gp.CloseFigure( )
Return gp
End Function

Private Function getHexPoints() As PointF()
Dim d As Single

d = CSng((Me.Width * Math.Sqrt(3)) / 4)

Dim hexPoints As PointF() = _
{New PointF(CSng(Me. Width / 2), 0), _
New PointF(CSng(Me. Width / 2) + d, CSng(Me.Width / 4)), _
New PointF(CSng(Me. Width / 2) + d, CSng(3 * (Me.Width /
4))), _
New PointF(CSng(Me. Width / 2), Me.Width), _
New PointF(CSng(Me. Width / 2) - d, CSng(3 * (Me.Width /
4))), _
New PointF(CSng(Me. Width / 2) - d, CSng(Me.Width / 4))}

Return hexPoints
End Function

End Class

Jun 20 '07 #6

"Chris Dunaway" <du******@gmail .comwrote in message
news:11******** **************@ o61g2000hsh.goo glegroups.com.. .
On Jun 20, 12:41 pm, Chris Dunaway <dunaw...@gmail .comwrote:
On Jun 19, 4:51 pm, Chris Dunaway <dunaw...@gmail .comwrote:


<snip>

Ok, I couldn't leave well enough alone. I changed it again, so that
you can set the backcolor, forecolor and I added properties for
BorderColor and BorderWidth.

Chris
[SNIP]

I can see there is a lot of new syntax I need to learn. Thank you very much
for showing me...

--
Timothy Casey GPEMC! >11950 is the nu****@fieldcra ft.com.au 2email
Terms & conditions apply. See www.fieldcraft.biz/GPEMC
Discover valid interoperable web menus, IE security, TSR Control,
& the most advanced speed reading application @ www.fieldcraft.biz
Jun 21 '07 #7

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

Similar topics

1
2054
by: David | last post by:
i am using the imagepolygon function to create a shape on an image i have, however i want to put more than just one polygon onto this image, i have no idea how to do this. Do i have to call the imageploygon function each time i want to add something to the image? All help is appreciated. Thanks Dave
3
2183
by: David | last post by:
Is it possible to create more than one polygon (using the imagepolygon function) and then paste them on to one image? i have no idea how to do this. I did post this a few days ago but my computer seems to have lost the reply, thanks Dave
1
3338
by: smjmitchell | last post by:
Hi All, I am developing a application in VB 6.0. I need to plot a 3D mesh of quadrilateral and triangular polygons. I have this working OK in wireframe. The question I have is what is the easiest way to shade the polygons so that I can render the surface. Each polygon is defined by the coordinates in space of its corners. Initially I would be happy with a uniform shading (i.e. constant color) and that is really what I am asking for help...
2
2432
by: Pete | last post by:
Whats the easiest way of defining a shape and knowing if a point is with in it? parden the crude pseduocode... i want something like: Shape1 = p1,p2,p3,p4,p5,p6,p7,p8,p9,p10 pnt = x,y
3
2000
by: Merlin | last post by:
Design Problem =============== Would appreciate any help or suggestion on this design issue. I have spent a great deal of time and effort for an elegant solution but it seems I am not getting anywhere... I have simplified my design problem to the following: Consider the following classes:
29
1974
by: Hamish | last post by:
I'm trying to use an C API which is for geometry calculations. The function requires an argument for an array of polygons: coordpt **polygons //-1] where coordpt is: typedef struct { double x;
1
2631
by: weberwhennner | last post by:
Hi All, Since two days Ive been trying to draw lines and polygons interactively (using mouse clicks), but all ive found is some libraries that draw shapes using predefined cooredinates. Ive also been trying to search for books on amazon that would help me learn more about this, but looks like I'm not using the right search terms... Any pointers, examples or related links would be greatly appreciated. Thanks a lot!
8
2720
by: Hypnotik | last post by:
Hey everyone. I'm writing a program which allows the user to enter information about 2 shapes, either a square, triangle, or rectangle, then 'adds' the shaps together. The resulting shape is a polygon. I understand how this is done, just not sure about the code. I need to overload the + operator to add the shapes. Also I know that I need to make a comparison between sides begin combined, and subtract the smaller side from the area. Also I...
1
4991
by: nttamdn | last post by:
Anyone help me please. I want anytime mousemove to one polygon, it's opacity becomes 0.3, and mouseout polygon, i'ts opacity return to 0 again. I means mousemove to show the polygon and hiding it when mouseout. I parsed points from XML and then add polygons to the map. But my problem that I can't addListener (mousemove) and (mouseout) for each of polygon, so I decide to addListener to the map and check if any polygon contains clicked point....
0
8384
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8718
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8499
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8601
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7314
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1937
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.