473,408 Members | 2,839 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,408 software developers and data experts.

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****@fieldcraft.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 1363
On Jun 19, 3:36 am, "Number 11950 - GPEMC! Replace number with 11950"
<num...@fieldcraft.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...@fieldcraft.com.au 2email
Terms & conditions apply. Seewww.fieldcraft.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*********************@q75g2000hsh.googlegro ups.com...
On Jun 19, 3:36 am, "Number 11950 - GPEMC! Replace number with 11950"
<num...@fieldcraft.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...@fieldcraft.com.au 2email
Terms & conditions apply. Seewww.fieldcraft.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****@fieldcraft.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...@fieldcraft.bizwrote:
"Chris Dunaway" <dunaw...@gmail.comwrote in message

news:11*********************@q75g2000hsh.googlegro ups.com...
On Jun 19, 3:36 am, "Number 11950 - GPEMC! Replace number with 11950"
<num...@fieldcraft.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...@fieldcraft.com.au 2email
Terms & conditions apply. Seewww.fieldcraft.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...@fieldcraft.com.au 2email
Terms & conditions apply. Seewww.fieldcraft.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.PaintEventArgs)

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

'pevent.Graphics.FillRegion(Brushes.Blue, Me.Region)

MyBase.OnPaint(pevent)
End Sub

Private Sub setRegion()
Dim gp As New Drawing2D.GraphicsPath()

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(hexPoints)
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...@fieldcraft.bizwrote:
"Chris Dunaway" <dunaw...@gmail.comwrote in message
news:11*********************@q75g2000hsh.googlegro ups.com...
On Jun 19, 3:36 am, "Number 11950 - GPEMC! Replace number with 11950"
<num...@fieldcraft.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...@fieldcraft.com.au 2email
Terms & conditions apply. Seewww.fieldcraft.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...@fieldcraft.com.au 2email
Terms & conditions apply. Seewww.fieldcraft.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.PaintEventArgs)

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

'pevent.Graphics.FillRegion(Brushes.Blue, Me.Region)

MyBase.OnPaint(pevent)
End Sub

Private Sub setRegion()
Dim gp As New Drawing2D.GraphicsPath()

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(hexPoints)
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(ControlStyles.AllPaintingInWmPaint Or _
ControlStyles.UserPaint Or _
ControlStyles.OptimizedDoubleBuffer, True)
End Sub

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

'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(hexPoints)
'Create a Pen to draw with
Using p As New Pen(Color.Red, 5)

'Draw the background of the button
pevent.Graphics.FillPath(Brushes.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.LineAlignment = StringAlignment.Center
sf.Trimming = StringTrimming.Word

Dim rc As New RectangleConverter

pevent.Graphics.DrawString(Me.Text, Me.Font,
Brushes.White, Me.ClientRectangle, 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.EventArgs)
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.Dispose()
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(getHexPoints())
gp.CloseFigure()
Return gp
End Function

Private Function getPath(ByVal hexPoints As PointF()) As
GraphicsPath
Dim gp As New GraphicsPath()
gp.AddPolygon(hexPoints)
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(ControlStyles.AllPaintingInWmPaint Or _
ControlStyles.UserPaint Or _
ControlStyles.OptimizedDoubleBuffer, True)

_borderColor = Me.ForeColor
_borderWidth = 3
End Sub

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

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

Dim hexPoints As PointF() = getHexPoints()

Using gp As GraphicsPath = getPath(hexPoints)
Using p As New Pen(Me.BorderColor, Me.BorderWidth)

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

pevent.Graphics.DrawPolygon(p, hexPoints)

Dim sf As New StringFormat

sf.Alignment = StringAlignment.Center
sf.LineAlignment = StringAlignment.Center
sf.Trimming = StringTrimming.Word

Dim rc As New RectangleConverter

Using br As New SolidBrush(Me.ForeColor)
pevent.Graphics.DrawString(Me.Text, Me.Font, br,
Me.ClientRectangle, 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.EventArgs)
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.Dispose()
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(getHexPoints())
gp.CloseFigure()
Return gp
End Function

Private Function getPath(ByVal hexPoints As PointF()) As
GraphicsPath
Dim gp As New GraphicsPath()
gp.AddPolygon(hexPoints)
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.googlegr oups.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****@fieldcraft.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
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...
3
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...
1
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...
2
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
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...
29
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 {...
1
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...
8
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.